The string type is broken
31–40 of 230 posts
Re: The string type is broken
#32Do people really need to reverse strings in the real world? I don't think I've ever written code to do that outside of homework assignments and interviews.
Re: The string type is broken
#33Re: The string type is broken
#34Re: The string type is broken
#35Re: The string type is broken
#36Re: The string type is broken
#37ICU has support for a lot of the basic operations you would want to perform on strings as well as conversion to whatever format is suitable for your platform and environment.
Re: The string type is broken
#38I think the mistake here is seeing a string as an extension of an array or vector. What I would prefer is a string type that didn't support all the operations of vectors. The length of a string is not inherently a meaningful question (and for the cases where it is, what you want is something like a vector of grapheme clusters - which is a useful type to have, but not so useful that every string in your program should…
Re: The string type is broken
#39That's because in a truly sane languages there should be a distinction between data type and its implementation. Then it would be not "string" type, that's broken, but an implementation of "string" type.
Re: The string type is broken
#40 $ perl -E 'use utf8; binmode STDOUT, ":utf8"; say uc("baffle");'
BAFFLEThe only failure I can see is that it treats "noel" as 5 characters (so reports length as 5 and reversing places the accent on the wrong character). That's documented here: http://perldoc.perl.org/perluniintro.html#Handling-Unicode "Note that Perl considers grapheme clusters to be separate characters"
All else seems to work though (including precomposed/decomoposed string equiality etc). The docco also says that perl's regex engine with Do The Right Thing with matching the entire grapheme cluster as a single char.