Skip to content

Commit 07ce5f1

Browse files
committed
- utf16 length detection was incorrect for utf16 with surrogate pairs.
1 parent f9b3552 commit 07ce5f1

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

lib/std/core/conv.c3

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ macro sz utf8_len_for_char16(Char16 c) @local
289289
{
290290
switch
291291
{
292-
case c & UTF16_SURROGATE_GENERIC_MASK == UTF16_SURROGATE_GENERIC_VALUE: return 4;
292+
case c & UTF16_SURROGATE_MASK == UTF16_SURROGATE_HIGH_VALUE: return 4;
293+
case c & UTF16_SURROGATE_MASK == UTF16_SURROGATE_LOW_VALUE: return 0;
293294
case c <= 0x7f: return 1;
294295
case c <= 0x7ff: return 2;
295296
default: return 3;

releasenotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
- `conv::utf8to32` would not zero terminate in when the zero would be at the end of the buffer.
8888
- `char16_to_utf8_unsafe` would not load low byte unaligned when required.
8989
- Not all invalid UTF8 was detected.
90+
- UTF16 length detection was incorrect for utf16 with surrogate pairs.
9091

9192
## 0.8.0 Change list
9293

0 commit comments

Comments
 (0)