[*] Disgusting locale subsystem: gross bug
This commit is contained in:
parent
f717511a10
commit
8002d6cba2
@ -56,13 +56,21 @@ namespace Aurora::Locale::Encoding
|
||||
{
|
||||
length = CountUTF8Length({in, length}, true);
|
||||
|
||||
auto readable = AuMin(length, utf8Max);
|
||||
if (utf8 && in)
|
||||
if (utf8Max)
|
||||
{
|
||||
AuMemcpy(utf8, in, readable);
|
||||
auto readable = AuMin(length, utf8Max);
|
||||
|
||||
readable = CountUTF8Length({in, readable}, true);
|
||||
|
||||
if (utf8 && in)
|
||||
{
|
||||
AuMemcpy(utf8, in, readable);
|
||||
}
|
||||
|
||||
return {readable, readable};
|
||||
}
|
||||
|
||||
return {readable, utf8 ? readable : length};
|
||||
return {length, length};
|
||||
}
|
||||
|
||||
// never remove me. the stl and windows can't bet trusted to fail on conversion failure.
|
||||
|
@ -27,18 +27,30 @@ namespace Aurora::Locale::Encoding
|
||||
AUKN_SYM AuStreamReadWrittenPair_t DecodeUTF8(const AuMemoryViewRead &binary, AuString &out, ECodePage page)
|
||||
{
|
||||
auto aaa = DecodeUTF8(binary, {}, page);
|
||||
out.resize(aaa.second);
|
||||
if (!AuTryResize(out, aaa.second))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
auto ret = DecodeUTF8(binary, Memory::MemoryViewWrite(out.data(), out.size()), page);
|
||||
out.resize(ret.second);
|
||||
if (!AuTryResize(out, aaa.second))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuStreamReadWrittenPair_t DecodeUTF8(void *binary, AuUInt32 binaryLength, AuString &out, ECodePage page)
|
||||
{
|
||||
auto aaa = DecodeUTF8(Memory::MemoryViewRead(binary, binaryLength), {}, page);
|
||||
out.resize(aaa.second);
|
||||
if (!AuTryResize(out, aaa.second))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
auto ret = DecodeUTF8(Memory::MemoryViewRead(binary, binaryLength), Memory::MemoryViewWrite(out.data(), out.size()), page);
|
||||
out.resize(ret.second);
|
||||
if (!AuTryResize(out, aaa.second))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -56,7 +68,7 @@ namespace Aurora::Locale::Encoding
|
||||
|
||||
/// Endian swap
|
||||
|
||||
AUKN_SYM void SwapUTF32(const Memory::MemoryViewWrite &utf32)
|
||||
AUKN_SYM void SwapUTF32(const AuMemoryViewWrite &utf32)
|
||||
{
|
||||
UTF32::SwapU32(utf32.Begin<AuUInt32>(), utf32.ToCount<AuUInt32>());
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace Aurora::Locale::Encoding::UTF16
|
||||
static void SwapU16(void *base, AuUInt32 count)
|
||||
{
|
||||
count *= 2;
|
||||
for (int i = 0; i < count; i += 2)
|
||||
for (AuUInt32 i = 0; i < count; i += 2)
|
||||
{
|
||||
AuWriteU16BE(base, i, AuReadU16LE(base, i));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace Aurora::Locale::Encoding::UTF32
|
||||
static void SwapU32(void *base, AuUInt32 count)
|
||||
{
|
||||
count *= 4;
|
||||
for (int i = 0; i < count; i += 4)
|
||||
for (AuUInt32 i = 0; i < count; i += 4)
|
||||
{
|
||||
AuWriteU32BE(base, i, AuReadU32LE(base, i));
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ namespace Aurora::Locale::Encoding::UTF8
|
||||
bool bUpdate = cp;
|
||||
|
||||
while ((it < end) && // can consooooome
|
||||
(bUpdate && cp < cpEnd))
|
||||
((bUpdate && cp < cpEnd) || !bUpdate))
|
||||
{
|
||||
AuUInt32 c = 0;
|
||||
if (*it <= 0x7FU)
|
||||
@ -122,7 +122,7 @@ namespace Aurora::Locale::Encoding::UTF8
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((end - it) < nby)
|
||||
if (AuUInt(end - it) < AuUInt(nby))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user