blob: 24a0bd5800d127e7fa3cbc4713b9a08995f6232f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
To allow opening files on Unicode paths on Windpws, expect passed 8-bit
strings to be UTF-8-encoded, and convert them to wchar_t. Fallback to
ACP strings for backward compatibility.
diff --git a/src/Numbertext.cxx b/src/Numbertext.cxx
--- a/src/Numbertext.cxx
+++ b/src/Numbertext.cxx
@@ -27,7 +27,11 @@
bool readfile(const std::string& filename, std::wstring& result)
{
#ifdef _WIN32
- std::ifstream ifs(filename);
+ // First try to convert from UTF-8
+ std::ifstream ifs(Numbertext::string2wstring(filename));
+ // Fallback to ACP string for backward compatibility
+ if (ifs.fail())
+ ifs.open(filename);
if (ifs.fail())
return false;
std::stringstream ss;
|