mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
Fix to a UTF-8 conversion operator for certain high value unicode points.
This commit is contained in:
parent
08805ac164
commit
449bfb852a
3 changed files with 7 additions and 20 deletions
|
|
@ -90,9 +90,9 @@ public:
|
|||
uint32 n = (uint32) (uint8) byte;
|
||||
uint32 mask = 0x7f;
|
||||
uint32 bit = 0x40;
|
||||
size_t numExtraValues = 0;
|
||||
int numExtraValues = 0;
|
||||
|
||||
while ((n & bit) != 0 && bit > 0x10)
|
||||
while ((n & bit) != 0 && bit > 0x8)
|
||||
{
|
||||
mask >>= 1;
|
||||
++numExtraValues;
|
||||
|
|
@ -101,9 +101,9 @@ public:
|
|||
|
||||
n &= mask;
|
||||
|
||||
for (size_t i = 1; i <= numExtraValues; ++i)
|
||||
for (int i = 1; i <= numExtraValues; ++i)
|
||||
{
|
||||
const uint8 nextByte = (uint8) data [i];
|
||||
const uint32 nextByte = (uint32) (uint8) data[i];
|
||||
|
||||
if ((nextByte & 0xc0) != 0x80)
|
||||
break;
|
||||
|
|
@ -312,9 +312,8 @@ public:
|
|||
static size_t getBytesRequiredFor (CharPointer text) noexcept
|
||||
{
|
||||
size_t count = 0;
|
||||
juce_wchar n;
|
||||
|
||||
while ((n = text.getAndAdvance()) != 0)
|
||||
while (juce_wchar n = text.getAndAdvance())
|
||||
count += getBytesRequiredFor (n);
|
||||
|
||||
return count;
|
||||
|
|
|
|||
|
|
@ -331,15 +331,8 @@ public:
|
|||
template <typename DestCharPointerType, typename SrcCharPointerType>
|
||||
static void copyAll (DestCharPointerType& dest, SrcCharPointerType src) noexcept
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = src.getAndAdvance();
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
while (juce_wchar c = src.getAndAdvance())
|
||||
dest.write (c);
|
||||
}
|
||||
|
||||
dest.writeNull();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,12 +86,7 @@ public:
|
|||
if (text.getAddress() == nullptr || text.isEmpty())
|
||||
return CharPointerType (&(emptyString.text));
|
||||
|
||||
CharPointer t (text);
|
||||
size_t bytesNeeded = sizeof (CharType);
|
||||
|
||||
while (! t.isEmpty())
|
||||
bytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance());
|
||||
|
||||
const size_t bytesNeeded = sizeof (CharType) + CharPointerType::getBytesRequiredFor (text);
|
||||
const CharPointerType dest (createUninitialisedBytes (bytesNeeded));
|
||||
CharPointerType (dest).writeAll (text);
|
||||
return dest;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue