diff options
author | yinsimei | 2017-07-06 22:05:13 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-13 18:27:45 +0200 |
commit | 302c94627930e9965f7607497a01201fff3551e3 (patch) | |
tree | f2301bea76f41412199c16bdb5e1bcee4fdbace9 /engines/sludge/builtin.cpp | |
parent | fe773c1bebf353bdba2a4a279b19a85ea4d7be5a (diff) | |
download | scummvm-rg350-302c94627930e9965f7607497a01201fff3551e3.tar.gz scummvm-rg350-302c94627930e9965f7607497a01201fff3551e3.tar.bz2 scummvm-rg350-302c94627930e9965f7607497a01201fff3551e3.zip |
SLUDGE: use U32String to replace sludge utf8 library
Diffstat (limited to 'engines/sludge/builtin.cpp')
-rw-r--r-- | engines/sludge/builtin.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index 1f19fc3b14..fc92161e3c 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -50,7 +50,7 @@ #include "sludge/thumbnail.h" #include "sludge/graphics.h" #include "sludge/sludge.h" -#include "sludge/CommonCode/utf8.h" +#include "sludge/utf8.h" namespace Sludge { @@ -558,9 +558,12 @@ builtIn(substring) { wholeString = getTextFromAnyVar(fun->stack->thisVar); trimStack(fun->stack); - if (u8_strlen(wholeString) < start + length) { - length = u8_strlen(wholeString) - start; - if (u8_strlen(wholeString) < start) { + UTF8Converter convert(wholeString); + Common::U32String str32 = convert.getU32String(); + + if (str32.size() < start + length) { + length = str32.size() - start; + if (str32.size() < start) { start = 0; } } @@ -568,8 +571,8 @@ builtIn(substring) { length = 0; } - int startoffset = u8_offset(wholeString, start); - int endoffset = u8_offset(wholeString, start + length); + int startoffset = convert.getOriginOffset(start); + int endoffset = convert.getOriginOffset(start + length); newString = new char[endoffset - startoffset + 1]; if (!checkNew(newString)) { @@ -580,7 +583,7 @@ builtIn(substring) { newString[endoffset - startoffset] = 0; makeTextVar(fun->reg, newString); - delete newString; + delete []newString; return BR_CONTINUE; } |