You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std.base64 fails on unicode strings with codepoints > 255 (emoji, CJK, etc.) #887
std.base64() fails when the input string contains characters with codepoints greater than 255, such as emoji, CJK characters, and other non-Latin scripts.
Reproduction
std.base64("🎉")
Expected Behavior
"8J+OiQ=="
(This is the correct base64 encoding of the UTF-8 bytes f0 9f 8e 89 for 🎉)
Actual Behavior
RUNTIME ERROR: base64 encountered invalid codepoint value in the array (must be 0 <= X <= 255), got 127881
More Examples
std.base64("你好") // fails - Chinese charactersstd.base64("مرحبا") // fails - Arabic charactersstd.base64("héllo") // works - all codepoints <= 255std.base64("hello") // works - ASCII
The implementation appears to convert the string to an array of Unicode codepoints and then try to treat each codepoint as a byte. This fails for any character with a codepoint > 255.
Activity