Skip to content

Commit a2c1fcc

Browse files
tonyfettesCopilot
authored andcommitted
fix: extract ch - 0x10000
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0caa7a1 commit a2c1fcc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

encoding/utf8/decode.mbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ pub fn decode_lossy(bytes : BytesView, ignore_bom? : Bool = false) -> String {
226226
((b1.to_int() & 0x3F) << 12) |
227227
((b2.to_int() & 0x3F) << 6) |
228228
(b3.to_int() & 0x3F)
229-
let ch1 = ((ch - 0x10000) >> 10) + 0xD800
230-
let ch2 = ((ch - 0x10000) & 0x3FF) + 0xDC00
229+
let chm = ch - 0x10000
230+
let ch1 = (chm >> 10) + 0xD800
231+
let ch2 = (chm & 0x3FF) + 0xDC00
231232
t.unsafe_set(tlen, ch1.to_byte())
232233
t.unsafe_set(tlen + 1, (ch1 >> 8).to_byte())
233234
t.unsafe_set(tlen + 2, ch2.to_byte())

0 commit comments

Comments
 (0)