@@ -10,16 +10,16 @@ index 5b3b153336..8696aaf927 100644
1010
1111 #include "unicode/udata.h"
1212
13- - static void* win_mmap(const char * dataFile) {
13+ - static void* win_mmap(const wchar_t * dataFile) {
1414- if (!dataFile) {
1515- return nullptr;
1616- }
17- + static void* win_mmap(const std::string & dataFile, std::ostringstream& buffer) {
17+ + static void* win_mmap(const std::wstring & dataFile, std::ostringstream& buffer) {
1818 struct FCloseWrapper { void operator()(FILE* f) { fclose(f); } };
19- - std::unique_ptr<FILE, FCloseWrapper> stream(fopen (dataFile, "rb"));
20- + std::unique_ptr<FILE, FCloseWrapper> stream(fopen (dataFile.c_str(), "rb"));
19+ - std::unique_ptr<FILE, FCloseWrapper> stream(_wfopen (dataFile, L "rb"));
20+ + std::unique_ptr<FILE, FCloseWrapper> stream(_wfopen (dataFile, L "rb"));
2121 if (!stream) {
22- - fprintf(stderr, "SkIcuLoader: datafile missing: %s .\n", dataFile);
22+ - fprintf(stderr, "SkIcuLoader: datafile missing: %ls .\n", dataFile);
2323+ buffer << "SkLoadICU: datafile '" << dataFile << "' is missing" << std::endl;
2424 return nullptr;
2525 }
@@ -51,11 +51,11 @@ index 5b3b153336..8696aaf927 100644
5151 }
5252 return addr;
5353@@ -86,23 +84,20 @@ static std::string executable_directory() {
54- return end ? std::string(path, end - path) : std::string( );
54+ return get_module_path(hModule );
5555 }
5656
57- - static bool load_from(const std::string & dir) {
58- - auto sPath = dir + "\\icudtl.dat";
57+ - static bool load_from(const std::wstring & dir) {
58+ - auto sPath = dir + L "\\icudtl.dat";
5959- if (void* addr = win_mmap(sPath.c_str())) {
6060- if (init_icu(addr)) {
6161- return true;
@@ -71,9 +71,9 @@ index 5b3b153336..8696aaf927 100644
7171 std::call_once(flag, []() {
7272- good = load_from(executable_directory()) || load_from(library_directory());
7373+ std::ostringstream buffer;
74- + void* addr = win_mmap(library_directory() + "\\icudtl.dat", buffer);
74+ + void* addr = win_mmap(library_directory() + L "\\icudtl.dat", buffer);
7575+ if (addr == nullptr)
76- + addr = win_mmap(executable_directory() + "\\icudtl.dat", buffer);
76+ + addr = win_mmap(executable_directory() + L "\\icudtl.dat", buffer);
7777+ if (addr == nullptr)
7878+ fputs(buffer.str().c_str(), stderr);
7979+ if (addr)
0 commit comments