Re: File.new and encoding



nobu@xxxxxxxxxxxxx wrote:

It would be UTF-8 encoded BOM, but ruby itself never write it
automatically.
[...]
Can't you show the code?

Trying to reproduce the problem in a smaller example, I figured out, that I'm reading the BOM from one of my source files. Sorry for the confusion. I'm doing something like:


File.open("target","w") do |target|
    File.open("source","r") do |source|
        source.each_line do |line|
            ... some processing ...
            target.write(line)
        end
     end
end


source seems to contain the BOM and it is writen to target. Any hint on how to strip the BOM?


regards,
Achim
.



Relevant Pages

  • Re: Windows nuisance character in .txt files
    ... I looked up BOM and it is indeed my nuisance ... The odd thing is that I am reading the file with: ... That will break for line 1 of a config file. ...
    (comp.lang.java.programmer)
  • WRONG ITEM NUMBERS IN BALLONS
    ... When i edit the bom the item numbers refenced in ... the ballons get all screwed up. ... I remeber ... reading about this before. ...
    (comp.cad.solidworks)
  • RE: Recurrencing
    ... The sample of Itzik works fine and Celko gave me a hint ... how can I improve this querry with BOM ... Regards ...
    (microsoft.public.sqlserver.programming)
  • Re: encoding
    ... You must have Byte Order Mark header written to the beginning of your ... You might want to read about BOM: ...
    (microsoft.public.vc.language)
  • remove BOM from string read from utf-8 file
    ... If I pass this text to a COM object, I can see that there is still the BOM ... character in the string is not ok, ... What's the right way to remove the BOM from the string? ...
    (comp.lang.python)