diff options
author | RichieSams | 2013-09-17 11:05:49 -0500 |
---|---|---|
committer | RichieSams | 2013-09-17 11:05:49 -0500 |
commit | d06c64d0762eb5f4b3f32c5402d05e801bb80ed8 (patch) | |
tree | f8873aa2b011bd6dede4c0c8db06f96566ce1624 | |
parent | 6148a0a878eb543731653870fcb369a8c86a2dfc (diff) | |
download | scummvm-rg350-d06c64d0762eb5f4b3f32c5402d05e801bb80ed8.tar.gz scummvm-rg350-d06c64d0762eb5f4b3f32c5402d05e801bb80ed8.tar.bz2 scummvm-rg350-d06c64d0762eb5f4b3f32c5402d05e801bb80ed8.zip |
ZVISION: Append chars to a Common::String object instead of using a static buffer
-rw-r--r-- | engines/zvision/string_manager.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp index 4c4fc7b168..8c7e0aaa3d 100644 --- a/engines/zvision/string_manager.cpp +++ b/engines/zvision/string_manager.cpp @@ -212,15 +212,13 @@ void StringManager::parseTag(const Common::String &tagString, uint lineNumber) { } Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { - // NOTE: Hardcoded size. All strings I've checked are less than 290 chars - char asciiString[300]; + Common::String asciiString; // Don't spam the user with warnings about UTF-16 support. // Just do one warning per String bool charOverflowWarning = false; uint16 value = stream.readUint16LE(); - uint i = 0; while (!stream.eos()) { // Check for CRLF if (value == 0x0A0D) { @@ -233,12 +231,11 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { // Crush each octet pair to a single octet with a simple cast if (value > 255) { charOverflowWarning = true; - value = 255; + value = '?'; } char charValue = (char)value; - asciiString[i] = charValue; - i++; + asciiString += charValue; value = stream.readUint16LE(); } @@ -247,7 +244,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { warning("UTF-16 is not supported. Characters greater than 255 are clamped to 255"); } - return Common::String(asciiString, i); + return asciiString; } StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) { |