diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-09-29 14:37:01 +0200 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-09-29 14:37:01 +0200 |
commit | 347402d20d7ecaab3daad691eb178c5a04447d44 (patch) | |
tree | 4a3188eef6087a3029b348cbbe8c93e5d365d158 /src/StringUtils.cpp | |
parent | Fixed SetDefaultRank() return value. (diff) | |
parent | Merge pull request #1479 from SphinxC0re/master (diff) | |
download | cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.tar cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.tar.gz cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.tar.bz2 cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.tar.lz cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.tar.xz cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.tar.zst cuberite-347402d20d7ecaab3daad691eb178c5a04447d44.zip |
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r-- | src/StringUtils.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 73147eebc..21962f832 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -441,10 +441,10 @@ static bool isLegalUTF8(const unsigned char * source, int length) -AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16) +AString UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length) { - a_UTF16.clear(); - a_UTF16.reserve(a_UTF8Length * 3); + AString UTF16; + UTF16.reserve(a_UTF8Length * 3); const unsigned char * source = (const unsigned char*)a_UTF8; const unsigned char * sourceEnd = source + a_UTF8Length; @@ -458,12 +458,12 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; if (source + extraBytesToRead >= sourceEnd) { - return a_UTF16; + return UTF16; } // Do this check whether lenient or strict if (!isLegalUTF8(source, extraBytesToRead + 1)) { - return a_UTF16; + return UTF16; } // The cases all fall through. See "Note A" below. @@ -487,13 +487,13 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a ch = ' '; } unsigned short v = htons((unsigned short)ch); - a_UTF16.append((const char *)&v, 2); + UTF16.append((const char *)&v, 2); } else if (ch > UNI_MAX_UTF16) { // Invalid value, replace with a space unsigned short v = htons(' '); - a_UTF16.append((const char *)&v, 2); + UTF16.append((const char *)&v, 2); } else { @@ -501,11 +501,11 @@ AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a ch -= halfBase; unsigned short v1 = htons((ch >> halfShift) + UNI_SUR_HIGH_START); unsigned short v2 = htons((ch & halfMask) + UNI_SUR_LOW_START); - a_UTF16.append((const char *)&v1, 2); - a_UTF16.append((const char *)&v2, 2); + UTF16.append((const char *)&v1, 2); + UTF16.append((const char *)&v2, 2); } } - return a_UTF16; + return UTF16; } /* |