Any Swift developers who know how it fares on these things? I've heard it does much better, largely by virtue of the Character type being an extended grapheme cluster, but does it handle all these cases right?
The string type is broken (2013)
11–20 of 45 posts
Re: The string type is broken (2013)
#12Earlier quoted context omitted.
What does "table stakes" mean? Never heard that before.
"Baseline expectation". I think it comes from poker or something
Re: The string type is broken (2013)
#13Rust's string type doesn't have the mentioned problems: https://play.rust-lang.org/?version=stable&mode=debug&editio... Though I would bet this mainly has to do with being a language born in the age of the web. It seems like something that would be very hard to back-port (as opposed to designing for it from the beginning), but proper handling of Unicode is practically table-stakes for a new language in today's world.…
Elixir gets it right: https://replit.com/@natanbc/reverse
Re: The string type is broken (2013)
#14Rust's string type doesn't have the mentioned problems: https://play.rust-lang.org/?version=stable&mode=debug&editio... Though I would bet this mainly has to do with being a language born in the age of the web. It seems like something that would be very hard to back-port (as opposed to designing for it from the beginning), but proper handling of Unicode is practically table-stakes for a new language in today's world.…
It does for multi-codepoint characters (such as the rainbow flag): https://play.rust-lang.org/?version=stable&mode=debug&editio... Elixir gets it right: https://replit.com/@natanbc/reverse
According to this they added it to the standard library at one point but then broke it back out because the lookup tables were too large
Re: The string type is broken (2013)
#15Any Swift developers who know how it fares on these things? I've heard it does much better, largely by virtue of the Character type being an extended grapheme cluster, but does it handle all these cases right?
I recently did a little survey of string types across programming languages, and found that they display an immense variety of designs for a datatype so fundamental. Swift stakes out one of the most interesting points in the design space by completely encapsulating the internal representation and requiring all accessors to be explicit in whether they operate on the string's encoding (e.g. as UTF-8), its Unicode code…
Re: The string type is broken (2013)
#16Rust's string type doesn't have the mentioned problems: https://play.rust-lang.org/?version=stable&mode=debug&editio... Though I would bet this mainly has to do with being a language born in the age of the web. It seems like something that would be very hard to back-port (as opposed to designing for it from the beginning), but proper handling of Unicode is practically table-stakes for a new language in today's world.…
https://play.rust-lang.org/?version=stable&mode=debug&editio...
It looks like it still misses some of the cases (specifically with decomposed vs precomposed).
As a side note, it looks like the playground editor also doesn't correctly render some of the lengths (the cursor is 1 character off on the decomposed case)
Re: The string type is broken (2013)
#17Re: The string type is broken (2013)
#18Rust's string type doesn't have the mentioned problems: https://play.rust-lang.org/?version=stable&mode=debug&editio... Though I would bet this mainly has to do with being a language born in the age of the web. It seems like something that would be very hard to back-port (as opposed to designing for it from the beginning), but proper handling of Unicode is practically table-stakes for a new language in today's world.…
this isn't quite set up the way the article was mentioning. Here's with it set up correctly: https://play.rust-lang.org/?version=stable&mode=debug&editio... It looks like it still misses some of the cases (specifically with decomposed vs precomposed). As a side note, it looks like the playground editor also doesn't correctly render some of the lengths (the cursor is 1 character off on the decomposed case)
Edit: Having read about them, I guess I assumed that if my keyboard inputs an ë it's actually inputting those two underlying characters. Or to put it differently, I assumed there weren't two separate representations for the same character; that the "decomposed" and "precomposed" versions are one in the same, at the byte level. Learned something h̶o̶r̶r̶i̶f̶y̶i̶n̶g̶ new!
Re: The string type is broken (2013)
#19 let s = String::from("noël");
println!("Printable? {}", s);
println!("Countable? {}", s.chars().count());
println!("Reversable? {}", s.chars().rev().collect::());
println!("First three characters? {}", s.chars().take(3).collect::());
Output: Printable? noël
Countable? 4
Reversable? lëon
First three characters? noë
Repo for the "noël" example and "cats" example: https://github.com/joelparkerhenderson/demo-rust-string-issu...