From: Michal Suchanek Date: 2007-10-22T07:18:04+09:00 Subject: Re: Encoding::primary_encoding On 21/10/2007, Wolfgang N��dasi-Donner wrote: > Michal Suchanek schrieb: > > However, the IO encoding should be what the system uses - as specified > > by locale or similar mechanism. > > > A standard system encoding doesn't always exist. I'm using Windows (2000 and > XP), where several standard text enxodings are available and processable even by > the simple notepad editor: UTF-8, UTF-16(LE), UTF-16BE, and ANSI (Microsofts > naming). The Unicode encodings will be identified by the BOM, which must be > available for the Microsoft tools. The usage of a BOM is not necessary, but > possible, so it may be a standard situation to receive UTF-8 encoded data via > the net without BOM. Under this circumstances the user must be able to specify > the encoding. yes, I am not saying that the user should not be able to specify encoding. I am saying that the source file comment is the wrong place. It should apply to the souce file snd nothing more. On Windows the situation is quite problematic. Most software would expect the encoding for which your windows are localized. This usually means two codepages, one for DOS emulation, and another for other stuff. Many windows applications mix these two and produce garbled text. Also there are interfaces that should work in UTF-16 no matter what the localization is. Still you should accept STDIN in the correct codepage even if the ruby script is written in utf-8 as specified in its comment. It should be possible to override that but the script encoding comment is not the place. Thanks Michal