1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fixes for support of non-utf8 strings.

This commit is contained in:
jules 2013-09-06 16:21:17 +01:00
parent 779d5795fd
commit c429b2aa24
3 changed files with 12 additions and 6 deletions

View file

@ -76,7 +76,8 @@ struct TranslationHelpers
if (c == '"')
{
out << String (start, p);
parseStringLiteral (++p, out);
++p;
parseStringLiteral (p, out);
return;
}

View file

@ -614,18 +614,19 @@ void String::appendCharPointer (const CharPointerType startOfTextToAppend,
const CharPointerType endOfTextToAppend)
{
jassert (startOfTextToAppend.getAddress() != nullptr && endOfTextToAppend.getAddress() != nullptr);
jassert (startOfTextToAppend.getAddress() <= endOfTextToAppend.getAddress());
const size_t extraBytesNeeded = endOfTextToAppend.getAddress() - startOfTextToAppend.getAddress();
const int extraBytesNeeded = getAddressDifference (endOfTextToAppend.getAddress(),
startOfTextToAppend.getAddress());
jassert (extraBytesNeeded >= 0);
if (extraBytesNeeded > 0)
{
const size_t byteOffsetOfNull = getByteOffsetOfEnd();
preallocateBytes (byteOffsetOfNull + extraBytesNeeded);
preallocateBytes (byteOffsetOfNull + (size_t) extraBytesNeeded);
char* const newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull);
CharPointerType::CharType* const newStringStart = addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull);
memcpy (newStringStart, startOfTextToAppend.getAddress(), extraBytesNeeded);
CharPointerType (newStringStart + extraBytesNeeded).writeNull();
CharPointerType (addBytesToPointer (newStringStart, extraBytesNeeded)).writeNull();
}
}

View file

@ -122,6 +122,7 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle
MemoryOutputStream data;
data.writeFromInputStream (*in, onlyReadOuterDocumentElement ? 8192 : -1);
#if JUCE_STRING_UTF_TYPE == 8
if (data.getDataSize() > 2)
{
data.writeByte (0);
@ -141,6 +142,9 @@ XmlElement* XmlDocument::getDocumentElement (const bool onlyReadOuterDocumentEle
return parseDocumentElement (String::CharPointerType (text), onlyReadOuterDocumentElement);
}
}
#else
originalText = data.toString();
#endif
}
}