summaryrefslogtreecommitdiff
path: root/tools/msgenc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/msgenc')
-rw-r--r--tools/msgenc/Makefile3
-rw-r--r--tools/msgenc/msgenc.cpp9
2 files changed, 7 insertions, 5 deletions
diff --git a/tools/msgenc/Makefile b/tools/msgenc/Makefile
index f6ddc439..05253e8b 100644
--- a/tools/msgenc/Makefile
+++ b/tools/msgenc/Makefile
@@ -1,7 +1,6 @@
CXXFLAGS := -std=c++17 -O2 -Wall -Wno-switch
CFLAGS := -O2 -Wall -Wno-switch
-WSLENV ?= no
ifeq ($(OS),Windows_NT)
LDFLAGS += -lstdc++fs
else
@@ -9,11 +8,9 @@ UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
LDFLAGS += -lstdc++ -lc++ -lc
else
-ifneq ($(WSLENV),)
LDFLAGS += -lstdc++fs
endif
endif
-endif
CXX_SRCS := msgenc.cpp
HEADERS :=
diff --git a/tools/msgenc/msgenc.cpp b/tools/msgenc/msgenc.cpp
index bc5e9eab..314fbce1 100644
--- a/tools/msgenc/msgenc.cpp
+++ b/tools/msgenc/msgenc.cpp
@@ -49,7 +49,7 @@ u16string ReadTextFileU16LE(path filename) {
ss << "read error in " << filename;
throw runtime_error(ss.str());
}
- if (bom != u'\uFEFF') {
+ if (bom != u'\uFEFF' && bom != u'\uFFFE') {
stringstream ss;
ss << "invalid bom in " << filename;
throw runtime_error(ss.str());
@@ -63,7 +63,12 @@ u16string ReadTextFileU16LE(path filename) {
ss << "read error in " << filename;
throw runtime_error(ss.str());
}
- buf[count] = L'\0';
+ if (bom == u'\uFFFE') {
+ for (int i = 0; i < count; i++) {
+ buf[i] = (buf[i] << 8) | (buf[i] >> 8);
+ }
+ }
+ buf[count] = u'\0';
fclose(file);
return buf;
}