Skip to content

Commit 1d9730e

Browse files
committed
mcdx supports UTF-16
1 parent 1295663 commit 1d9730e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

mcdx/mcdx.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,29 @@ int save_bin(const char *output_file)
817817
return EXITCODE_SUCCESS;
818818
}
819819

820+
bool IsUTF16File(const char *input_file)
821+
{
822+
if (FILE *fp = fopen(input_file, "rb"))
823+
{
824+
char ab[2];
825+
if (fread(ab, 1, 2, fp) == 2)
826+
{
827+
if (memcmp(ab, "\xFF\xFE", 2) == 0)
828+
{
829+
fclose(fp);
830+
return true;
831+
}
832+
if (ab[0] && !ab[1])
833+
{
834+
fclose(fp);
835+
return true;
836+
}
837+
}
838+
fclose(fp);
839+
}
840+
return false;
841+
}
842+
820843
int load_rc(const char *input_file)
821844
{
822845
// definitions minus undefinitions
@@ -839,7 +862,10 @@ int load_rc(const char *input_file)
839862

840863
// build up command line
841864
MString command_line;
842-
command_line += g_cpp;
865+
if (IsUTF16File(input_file))
866+
command_line += "mcpp";
867+
else
868+
command_line += g_cpp;
843869
command_line += ' ';
844870
for (size_t i = 0; i < g_definitions.size(); ++i)
845871
{

src/Res.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,7 @@ struct EntrySet : protected EntrySetBase
22182218
}
22192219
}
22202220

2221-
if (bSuccess && !bUTF16)
2221+
if (bSuccess)
22222222
{
22232223
// load the message table if any
22242224
EntrySet es;

0 commit comments

Comments
 (0)