summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2020-08-03 16:07:07 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2020-08-03 16:07:07 -0400
commitb5dccf7bfc3c345501551229a4e65c6726d3b78b (patch)
treeae699225103bae10271f70797a6f2d2b31dce5d5
parent1570151045599e0556c95b42e38393d3241d5797 (diff)
Support UTF-16BE-BOM
-rw-r--r--tools/msgenc/msgenc.cpp9
1 files changed, 7 insertions, 2 deletions
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;
}