From: Dmitry Severin Date: 2006-06-19T14:57:22+09:00 Subject: Re: Unicode roadmap? ------=_Part_121828_33162151.1150696640121 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Correct me,if I'm wrong, but for Matz's plan on M17N, summary is: 1. String internally will remain the same : char *ptr, long len - in bytes 2. String instances will have encoding tag 3. All String/Regexp methods will respect that encoding tag and return char(glyph) indexes 4. Methods like byte_size, codepoints, each_char, each_codepoint will be introduced(?) 5. slice will always accept chars indices and return substrings I'd say that WOULD BE GOOD, and with methods like String#enforce_encoding!(encoding) and String#coerce_encoding!(otherstring) it won't require developers (for C extensions also) to look at encoding tag, just set it when needed. But, I can see several imlementation issues and possible options, that should be considered: - what will happen if one tries to perfom str1.operation(str2) on two strings with different encodings: a) raise exception b) silent coerce one or both strings to some "compatible" charset/encoding, update encoding of result, replacing non-convertable chars using fallback mappings? (ouch, this can be split to set of options) c) same as b) but raise exception if non-loss conversion is not possible? d) same as b) but warn if non-loss conversion is not possible? e) downgrade encoding tag of acceptor to "raw/bytes" and process it? - what will happen if one changes encoding tag for String instance: a) check and raise exception if current bytes don't represent valid encoding sequence? b) just set new tag? c) convert byte sequence to given encoding, using fallback mappings? - what to do with IO: a) IO will return strings in "raw/bytes"? b) IO can be tagged and will return Strings with given econding tag? c) IO can be tagged and is by default tagged with global encoding tag? d) IO can be tagged, but is not tagged by default, although methods returning strings (such as read, readlines) will use global encoding tag? e) if IO is tagged and one tries to write to it a String with different encoding, what will happen? - what will be default encoding tag for new Strings: a) "raw/bytes" b) derived from system properties of host platform c) option b) and can be overriden in application (btw, $KCODE, as present, must definitely go away!!!) - how to process source code files: a) restrict them to ASCII and require all non-ASCII strings to be externalized? b) process them as "raw/bytes"? c) introduce some kind of commented pragma for source files allowing to set encoding, - at present time Ruby parser can parse only sources in ASCII compatible encoding. Would it change? - what encodings will have Numeric.to_s, Time.to_s etc., or String has to have/conform for String#to_f, String#to_i? On Unicode: - case-independent canonical string matches/searches DO MATTER. And even for encodings, that code variants of glyphs with different codepoints "variant-insensitive" search, as for me, is desired. Will there be such functionality? - string comparison: will <=> use at least UCA rules for Unicode strings, or only byte-order comparisons will stay? - is_digit, is_space, is_alpha, is_foobarbaz etc. could matter, when writing a custom parser. Will those methods be provided for one-char strings? Yes, this is short and incomplete list, but, you should get my point: it's not that easy -- there are dozens of decisions, with their pros and cons, to be done and implemented :( ------=_Part_121828_33162151.1150696640121--