Skip to content

Commit 7127bff

Browse files
committed
When loading Unicode data into a 64-bit _UTF8Chunk, ensure that the chunk is in host endianness, for correct operations on both little- and big-endian systems.
1 parent 85fde8b commit 7127bff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

stdlib/public/core/StringUTF8.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ extension _StringCore {
4747
src: UnsafeMutablePointer(startASCII + i),
4848
size: numericCast(utf16Count))
4949

50-
return (i + utf16Count, result)
50+
// Convert the _UTF8Chunk into host endianness.
51+
return (i + utf16Count, _UTF8Chunk(littleEndian: result))
5152
} else if _fastPath(_baseAddress != nil) {
53+
// Transcoding should return a _UTF8Chunk in host endianness.
5254
return _encodeSomeContiguousUTF16AsUTF8(from: i)
5355
} else {
5456
#if _runtime(_ObjC)

0 commit comments

Comments
 (0)