From: James Gray Date: 2008-09-16T23:18:35+09:00 Subject: [ruby-core:18632] Re: Special warning for UTF-16? (was: Re: Re: Working on CSV's Encoding Support) On Sep 16, 2008, at 5:37 AM, Martin Duerst wrote: > At 00:43 08/09/15, James Gray wrote: > >>> I tried to test with UTF-16 as well, since I think that's a good >>> edge case. However, we don't seem to have a converter for that: >>> >>> $ ruby_dev ~/Desktop/regexp_encoding.rb # >>> # >>> /Users/james/Desktop/regexp_encoding.rb:15:in `encode': code >>> converter not found (US-ASCII to UTF-16) (Encoding::NoConverter) >>> from /Users/james/Desktop/regexp_encoding.rb:15:in `
' >> >> This was my fault. UTF-16 is not a valid encoding name. Once I >> switched to UTF-16LE or UTF-16BE it worked fine. > > Just thinking aloud: Although I'm the person who wrote most of the > original core for String#encode, and should therefore know best, > I've fallen in that trap several times. Given that, and the fact > that in the wild, UTF-16 is used quite frequently, suggests that > other people will make this error, too, and will have difficulties > to figure out what's wrong. > > So I'm suggesting that we produce some special error message for > UTF-16, such as "UTF-16 not available, use either UTF-16BE or > UTF-16LE". In general, I don't like such special-casing, but > given that Ruby tries to be user-friendly, it may be worth > doing. > > Any comments? I would be for that, or making UTF-16 an alias for UTF-16BE. James Edward Gray II