Fixed Alignment issue in ByteBuffer
This commit is contained in:
parent
2eca30aebc
commit
b78c729880
@ -767,7 +767,7 @@ bool cByteBuffer::ReadUTF16String(AString & a_String, int a_NumChars)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RawBEToUTF8((short *)(RawData.data()), a_NumChars, a_String);
|
RawBEToUTF8((RawData.data()), a_NumChars, a_String);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,13 +288,13 @@ void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString &
|
|||||||
|
|
||||||
|
|
||||||
// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
|
// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
|
||||||
AString & RawBEToUTF8(short * a_RawData, int a_NumShorts, AString & a_UTF8)
|
AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8)
|
||||||
{
|
{
|
||||||
a_UTF8.clear();
|
a_UTF8.clear();
|
||||||
a_UTF8.reserve(3 * a_NumShorts / 2); // a quick guess of the resulting size
|
a_UTF8.reserve(3 * a_NumShorts / 2); // a quick guess of the resulting size
|
||||||
for (int i = 0; i < a_NumShorts; i++)
|
for (int i = 0; i < a_NumShorts; i++)
|
||||||
{
|
{
|
||||||
int c = ntohs(*(a_RawData + i));
|
int c = GetBEShort(a_RawData + i*2);
|
||||||
if (c < 0x80)
|
if (c < 0x80)
|
||||||
{
|
{
|
||||||
a_UTF8.push_back((char)c);
|
a_UTF8.push_back((char)c);
|
||||||
@ -364,10 +364,7 @@ Notice from the original file:
|
|||||||
|
|
||||||
#define UNI_MAX_BMP 0x0000FFFF
|
#define UNI_MAX_BMP 0x0000FFFF
|
||||||
#define UNI_MAX_UTF16 0x0010FFFF
|
#define UNI_MAX_UTF16 0x0010FFFF
|
||||||
#define UNI_MAX_UTF32 0x7FFFFFFF
|
|
||||||
#define UNI_MAX_LEGAL_UTF32 0x0010FFFF
|
|
||||||
#define UNI_SUR_HIGH_START 0xD800
|
#define UNI_SUR_HIGH_START 0xD800
|
||||||
#define UNI_SUR_HIGH_END 0xDBFF
|
|
||||||
#define UNI_SUR_LOW_START 0xDC00
|
#define UNI_SUR_LOW_START 0xDC00
|
||||||
#define UNI_SUR_LOW_END 0xDFFF
|
#define UNI_SUR_LOW_END 0xDFFF
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ extern unsigned int RateCompareString(const AString & s1, const AString & s2 );
|
|||||||
extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export
|
extern void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & iReplaceWith); // tolua_export
|
||||||
|
|
||||||
/// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
|
/// Converts a stream of BE shorts into UTF-8 string; returns a ref to a_UTF8
|
||||||
extern AString & RawBEToUTF8(short * a_RawData, int a_NumShorts, AString & a_UTF8);
|
extern AString & RawBEToUTF8(const char * a_RawData, int a_NumShorts, AString & a_UTF8);
|
||||||
|
|
||||||
/// Converts a UTF-8 string into a UTF-16 BE string, packing that back into AString; return a ref to a_UTF16
|
/// Converts a UTF-8 string into a UTF-16 BE string, packing that back into AString; return a ref to a_UTF16
|
||||||
extern AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16);
|
extern AString & UTF8ToRawBEUTF16(const char * a_UTF8, size_t a_UTF8Length, AString & a_UTF16);
|
||||||
|
Loading…
Reference in New Issue
Block a user