MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / Windows1252ToUTF8

Function Windows1252ToUTF8

src/decoder/plugins/SidplayDecoderPlugin.cxx:400–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398}
399
400[[gnu::pure]]
401static AllocatedString
402Windows1252ToUTF8(const char *s) noexcept
403{
404#ifdef HAVE_ICU_CONVERTER
405 try {
406 return IcuConverter::Create("windows-1252")->ToUTF8(s);
407 } catch (...) { }
408#endif
409
410 /*
411 * Fallback to not transcoding windows-1252 to utf-8, that may result
412 * in invalid utf-8 unless nonprintable characters are replaced.
413 */
414 AllocatedString t(s);
415
416 for (size_t i = 0; t[i] != AllocatedString::SENTINEL; i++)
417 if (!IsPrintableASCII(t[i]))
418 t[i] = '?';
419
420 return t;
421}
422
423[[gnu::pure]]
424static AllocatedString

Callers 1

GetInfoStringFunction · 0.85

Calls 1

ToUTF8Method · 0.45

Tested by

no test coverage detected