I think, the idea of first reading the lines, and then use 
force_encoding on the strings, would not work for two reasons:

1. As I have experienced, I already get the exception on the first byte 
which has the high-bit set (i.e. is not 7-bit ASCII)

2. If a UTF8 encoded character contained 0x0d or 0x0a, reading the line 
without being aware of the encoding, would "split" the character into 
two parts.

In addition, this solution would not account for a BOM (unless I write 
special logic to extract an optional BOM on the first line being read). 
Although I have only files without BOM at the moment, it is likely that 
sooner or later I will also have to support uploading of files which 
contain a BOM.

Ronald

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/35dbf02bb1ed24e8c9bd25250ed049c4%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to