@@ -260,6 +260,11 @@ QString toUnicode(const std::string& toConvert) {
260260 ->toUnicode (toConvert.data (), static_cast <int >(toConvert.length ()));
261261}
262262
263+ QString convertComment (const std::string& toConvert) {
264+ int length = static_cast <int >(toConvert.length ()) - 2 ; // strip off trailing nullbyte
265+ return QTextCodec::codecForName (" UTF-16BE" )->toUnicode (toConvert.data (), length);
266+ }
267+
263268// Functions getText and parseDeviceDB are roughly based on the following Java file:
264269// https://github.com/Deep-Symmetry/crate-digger/commit/f09fa9fc097a2a428c43245ddd542ac1370c1adc
265270// getText is needed because the strings in the PDB file "have a variety of obscure representations".
@@ -997,7 +1002,7 @@ void readAnalyze(TrackPointer track,
9971002 memory_cue_loop_t memoryCue;
9981003 memoryCue.startPosition = position;
9991004 memoryCue.endPosition = mixxx::audio::kInvalidFramePos ;
1000- memoryCue.comment = toUnicode (cueExtendedEntry->comment ());
1005+ memoryCue.comment = convertComment (cueExtendedEntry->comment ());
10011006 memoryCue.color = colorFromID (static_cast <int >(
10021007 cueExtendedEntry->color_id ()));
10031008 memoryCuesAndLoops << memoryCue;
@@ -1016,7 +1021,7 @@ void readAnalyze(TrackPointer track,
10161021 loop.startPosition = position;
10171022 loop.endPosition = mixxx::audio::FramePos (
10181023 sampleRateKhz * static_cast <double >(endTime));
1019- loop.comment = toUnicode (cueExtendedEntry->comment ());
1024+ loop.comment = convertComment (cueExtendedEntry->comment ());
10201025 loop.color = colorFromID (static_cast <int >(cueExtendedEntry->color_id ()));
10211026 memoryCuesAndLoops << loop;
10221027 } break ;
@@ -1031,14 +1036,14 @@ void readAnalyze(TrackPointer track,
10311036 position,
10321037 mixxx::audio::kInvalidFramePos ,
10331038 hotCueIndex,
1034- toUnicode (cueExtendedEntry->comment ()),
1039+ convertComment (cueExtendedEntry->comment ()),
10351040 mixxx::RgbColor (qRgb (
10361041 static_cast <int >(
10371042 cueExtendedEntry->color_red ()),
10381043 static_cast <int >(
10391044 cueExtendedEntry->color_green ()),
10401045 static_cast <int >(cueExtendedEntry
1041- ->color_blue ()))));
1046+ ->color_blue ()))));
10421047 } break ;
10431048 }
10441049 }
0 commit comments