On Sep 16, 2008, at 8:20 PM, Michael Selig wrote:

> =85but UTF-16 is the problem - it breaks so many things, due to its =20=

> "ASCII incompatibility" (using Ruby's definition). I can't even do =20
> simple things like pull out fields and substitute into another =20
> string without testing "encoding compatibility". Something as simple =20=

> as:
>
> 	puts "The value is #{val}"
>
> fails if val is UTF-16 data.

How ironic=85  I ran into this issue about five minutes ago.  It's =20
killing the CSV implementation I thought I finally had right.  :(

How would you save this?  Instead of:

   %Q{"#{val}"}  # boom for UTF-16!

Can we do:

   ['"', val, '"'].map { |s| s.encode("UTF-16BE") }.join

?  Yeah, that seems to work.  It sucks, but it works.

James Edward Gray II=