summaryrefslogtreecommitdiff
path: root/src/PlaylistFile.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-10-18 10:05:26 +0200
committerMax Kellermann <max@musicpd.org>2017-10-18 10:05:26 +0200
commit9703a401c5ac3f679503b845805fe24db22c458c (patch)
treee0e481f9dd315c1b8ed065c7a024c4d9a740bb24 /src/PlaylistFile.cxx
parent753a2aa4622b2a116b510ae1ea41b3898c425955 (diff)
Playlist{File,Save}: always use UTF-8 in playlists on Windows
Turns out that using CP_ACP is a lousy idea, because only very few Unicode characters can be represented by it. Instead, switch to UTF-8 (which every sane person on other operating system already uses). Closes #102
Diffstat (limited to 'src/PlaylistFile.cxx')
-rw-r--r--src/PlaylistFile.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx
index 2deae4321..c1fcdeb3c 100644
--- a/src/PlaylistFile.cxx
+++ b/src/PlaylistFile.cxx
@@ -207,13 +207,12 @@ try {
continue;
#ifdef _UNICODE
- wchar_t buffer[MAX_PATH];
- auto result = MultiByteToWideChar(CP_ACP, 0, s, -1,
- buffer, ARRAY_SIZE(buffer));
- if (result <= 0)
+ /* on Windows, playlists always contain UTF-8, because
+ its "narrow" charset (i.e. CP_ACP) is incapable of
+ storing all Unicode paths */
+ const auto path = AllocatedPath::FromUTF8(s);
+ if (path.IsNull())
continue;
-
- const Path path = Path::FromFS(buffer);
#else
const Path path = Path::FromFS(s);
#endif