summaryrefslogtreecommitdiffstats
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-27 23:13:37 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-27 23:13:37 +0200
commit1f8ee70d55d0d076583e14329ca09377c41b12e0 (patch)
treeb9d021314c75e76c24895f3c2cc2b27744a9c900 /src/StringUtils.cpp
parentMerge remote-tracking branch 'origin/master' into endofsupport (diff)
downloadcuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.gz
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.bz2
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.lz
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.xz
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.zst
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.zip
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r--src/StringUtils.cpp20
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;
}
/*