utf-16 makes me sad
Conversation
Notices
-
Embed this notice
webbureaucrat (webbureaucrat@floss.social)'s status on Sunday, 05-Jan-2025 14:09:35 JST webbureaucrat
-
Embed this notice
alcinnz (alcinnz@floss.social)'s status on Sunday, 05-Jan-2025 14:09:41 JST alcinnz
@webbureaucrat Why?
-
Embed this notice
webbureaucrat (webbureaucrat@floss.social)'s status on Sunday, 05-Jan-2025 14:14:30 JST webbureaucrat
@alcinnz I'm building a JSON5 parser which supports escaping into UTF-16 which Rust doesn't really support natively in any meaningful way, so now I'm in analysis paralysis for how to handle that.
I think I'm going to allow the calling code to configure whether they want lossless or lossy conversion to Rust's UTF-8 strings, but which adds a good bit of complexity for both me and the user.
alcinnz repeated this. -
Embed this notice
Elias Mårtenson (loke@functional.cafe)'s status on Sunday, 05-Jan-2025 14:23:33 JST Elias Mårtenson
@alcinnz @webbureaucrat it should make one sad. It's the worst of both worlds, and the only reason for its existence is to make badly designed software kinda work.
-
Embed this notice
Elias Mårtenson (loke@functional.cafe)'s status on Sunday, 05-Jan-2025 14:24:04 JST Elias Mårtenson
@webbureaucrat @alcinnz JSON is such a horrific thing. Completely underspecified (only floats? Doesn't specify the float precision?), no comments, unnecessary quotes around the keywords and as you said, the weird features of string eacapes. All of this just to make sure you can eval the string in js, something that one should never do anyway.
-
Embed this notice
webbureaucrat (webbureaucrat@floss.social)'s status on Sunday, 05-Jan-2025 14:24:17 JST webbureaucrat
@alcinnz I guess I didn't phrase that very well.
By "lossless" here I mean `from_utf16` which parses into a `Result` as opposed to `from_utf16_lossy` which goes straight to a string. Obviously if there were a way to do this in a "lossless" way I would have fewer problems.
I am sleepy.
-
Embed this notice