diff options
Diffstat (limited to 'engines/mutationofjb/util.cpp')
-rw-r--r-- | engines/mutationofjb/util.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/engines/mutationofjb/util.cpp b/engines/mutationofjb/util.cpp index 1a56a62af6..6d7c02a293 100644 --- a/engines/mutationofjb/util.cpp +++ b/engines/mutationofjb/util.cpp @@ -33,5 +33,27 @@ void reportFileMissingError(const char *fileName) { warning("%s", errorMessage.c_str()); } +Common::String toUpperCP895(const Common::String &str) { + static const byte conversionTable[] = { + 0x00, 0x9A, 0x90, 0x85, 0x8E, 0x00, 0x00, 0x80, 0x89, 0x00, 0x00, 0x00, 0x9C, 0x8A, 0x00, 0x00, /* 0x80-0x8F */ + 0x00, 0x92, 0x00, 0xA7, 0x99, 0x00, 0xA6, 0x00, 0x9D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, /* 0x90-0x9F */ + 0x8F, 0x8B, 0x95, 0x97, 0xA5, 0x00, 0x00, 0x00, 0x9B, 0x9E, 0xAB, 0x00 /* 0xA0-0xAB */ + }; + + Common::String ret = str; + for (Common::String::iterator it = ret.begin(); it != ret.end(); ++it) { + const byte cp895Byte = reinterpret_cast<const byte &>(*it); + if (cp895Byte < 0x80) { + *it = static_cast<char>(toupper(*it)); + } else if (cp895Byte <= 0xAB) { + byte newChar = conversionTable[cp895Byte - 0x80]; + if (newChar != 0) { + reinterpret_cast<byte &>(*it) = newChar; + } + } + } + return ret; +} + } |