aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/utils/string_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/utils/string_util.cpp')
-rw-r--r--engines/wintermute/utils/string_util.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/engines/wintermute/utils/string_util.cpp b/engines/wintermute/utils/string_util.cpp
index 2c3be8c2f5..9fffad85cd 100644
--- a/engines/wintermute/utils/string_util.cpp
+++ b/engines/wintermute/utils/string_util.cpp
@@ -148,11 +148,11 @@ Utf8String StringUtil::wideToUtf8(const WideString &WideStr) {
// Currently this only does Ansi->ISO 8859, and only for carets.
char simpleAnsiToWide(const AnsiString &str, uint32 &offset) {
- char c = str[offset];
+ byte c = str[offset];
- if (c == 92) {
+ if (c == 146) {
offset++;
- return '\'';
+ return 39; // Replace right-quote with apostrophe
} else {
offset++;
return c;
@@ -162,11 +162,11 @@ char simpleAnsiToWide(const AnsiString &str, uint32 &offset) {
//////////////////////////////////////////////////////////////////////////
WideString StringUtil::ansiToWide(const AnsiString &str) {
// TODO: This function gets called a lot, so warnings like these drown out the usefull information
- /*Common::String converted = "";
+ Common::String converted = "";
uint32 index = 0;
while (index != str.size()) {
converted += simpleAnsiToWide(str, index);
- }*/
+ }
// using default os locale!
/* setlocale(LC_CTYPE, "");
@@ -176,7 +176,7 @@ WideString StringUtil::ansiToWide(const AnsiString &str) {
WideString ResultString(wstr);
delete[] wstr;
return ResultString;*/
- return WideString(str);
+ return WideString(converted);
}
//////////////////////////////////////////////////////////////////////////
@@ -205,7 +205,7 @@ bool StringUtil::isUtf8BOM(const byte *buffer, uint32 bufferSize) {
//////////////////////////////////////////////////////////////////////////
int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t startFrom) {
const char *index = strstr(str.c_str(), toFind.c_str());
- if (index == NULL) {
+ if (index == nullptr) {
return -1;
} else {
return index - str.c_str();
@@ -213,8 +213,10 @@ int StringUtil::indexOf(const WideString &str, const WideString &toFind, size_t
}
Common::String StringUtil::encodeSetting(const Common::String &str) {
- if (str.contains('=')) {
- error("Setting contains '='");
+ for (uint32 i = 0; i < str.size(); i++) {
+ if ((str[i] < 33) || (str[i] == '=') || (str[i] > 126)) {
+ error("Setting contains illegal characters: %s", str.c_str());
+ }
}
return str;
}