mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[stdlib] Add utf8 safeguards, fix `chr` method, add unicode and utf16 parsing for `String`

Open martinvuyk opened this issue 7 months ago • 0 comments

Add utf8 safeguards, the second of many steps to fix #2842

fn chr(c: Int) -> String function now returns a replacement character (�) if the Unicode codepoint is invalid.

Added String.from_unicode(values: List[Int]) -> String and String.from_utf16(values: List[UInt16]) -> String functions that return a String containing the concatenated characters. If a Unicode codepoint is invalid, the parsed String has a replacement character (�) in that index.

martinvuyk avatar Jul 13 '24 17:07 martinvuyk