> You are not allowed to set the source encoding to a non-ASCII
> compatible encoding, if memory serves. 

Where is it documented please?

> That eliminates any issues
> with encodings like UTF-16.  This makes perfect sense as there's no
> way to reliably support the magic encoding comment unless we can count
> on being able to read at least that far.

Needed to say that XML parsers can handle such cases, i.e. when xml 
header is in different encoding than the rest of document.

> A BOM could be handled similarly to what I showed.  You need to open
> the file in ASCII-8BIT and check the beginning bytes, then you could
> switch to US-ASCII and finish reading the first line (or to the second
> if a shebang line is includes), then switch encodings again if needed
> and finish processing.

May be this technique could be used for reading UTF-16 encoded files, if 
needed? However this is too far from my initial post :)

> 
> James Edward Gray II

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