diff options
author | Jaromir Wysoglad | 2019-08-19 18:22:50 +0200 |
---|---|---|
committer | Filippos Karapetis | 2019-08-24 18:12:45 +0300 |
commit | f8ac40af7c2b687d8dd3ce2f5909ab3f78f4a4bd (patch) | |
tree | ca9f8116790ab574762adf6f38202efa7a3f3e29 | |
parent | 6dba0bbfd421121056fba0d348794ead2928c662 (diff) | |
download | scummvm-rg350-f8ac40af7c2b687d8dd3ce2f5909ab3f78f4a4bd.tar.gz scummvm-rg350-f8ac40af7c2b687d8dd3ce2f5909ab3f78f4a4bd.tar.bz2 scummvm-rg350-f8ac40af7c2b687d8dd3ce2f5909ab3f78f4a4bd.zip |
COMMON: Encoding refactoring
-rw-r--r-- | common/encoding.cpp | 10 | ||||
-rw-r--r-- | common/encoding.h | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/common/encoding.cpp b/common/encoding.cpp index fa3085342a..089f0399c1 100644 --- a/common/encoding.cpp +++ b/common/encoding.cpp @@ -24,7 +24,7 @@ #include "common/textconsole.h" #include "common/system.h" #include "common/translation.h" -#include <cerrno> +#include <errno.h> namespace Common { @@ -246,22 +246,22 @@ char *Encoding::convertTransManMapping(const char *to, const char *from, const c String currentCharset = TransMan.getCurrentCharset(); if (currentCharset.equalsIgnoreCase(from)) { // We can use the transMan mapping directly - uint32 *partialResult = (uint32 *) calloc(sizeof(uint32), (strlen(string) + 1)); + uint32 *partialResult = (uint32 *) calloc(sizeof(uint32), (length + 1)); if (!partialResult) { warning("Couldn't allocate memory for encoding conversion"); return nullptr; } const uint32 *mapping = TransMan.getCharsetMapping(); if (mapping == 0) { - for(unsigned i = 0; i < strlen(string); i++) { + for(unsigned i = 0; i < length; i++) { partialResult[i] = string[i]; } } else { - for(unsigned i = 0; i < strlen(string); i++) { + for(unsigned i = 0; i < length; i++) { partialResult[i] = mapping[(unsigned char) string[i]] & 0x7FFFFFFF; } } - char *finalResult = convert(to, "UTF-32", (char *) partialResult, strlen(string) * 4); + char *finalResult = convert(to, "UTF-32", (char *) partialResult, length * 4); free(partialResult); return finalResult; } else if (currentCharset.equalsIgnoreCase(to) && String(from).hasPrefixIgnoreCase("utf-32")) { diff --git a/common/encoding.h b/common/encoding.h index 70ba2bfe44..7eb4251af1 100644 --- a/common/encoding.h +++ b/common/encoding.h @@ -22,6 +22,7 @@ #ifndef COMMON_ENCODING_H #define COMMON_ENCODING_H + #ifdef HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H |