From: Robert Klemme Date: 2010-07-27T18:01:46+09:00 Subject: Re: REXML Input File Question 2010/7/24 Mike Pe : > Robert Klemme wrote: >> On 19.07.2010 21:13, Mike Pe wrote: >>>       >>> EOF >> >> The string is most likely not UTF-16 encoded so REXML cannot parse it >> properly.  Which Ruby version?  If it is 1.9ish you'll find information >> about i18n here: >> http://blog.grayproductions.net/articles/understanding_m17n >> >>> puts doc.root.attributes["test"] -->  nil >>> >>> doc = Document.new noerror >>> puts doc.root.attributes["test"] -->  yes >>> >>> I considered the fact that REXML only takes in UTF-8 unicoded files, but >>> when I convert these files from UTF-16 to UTF-8, it still does not parse >>> properly. >>> >>> Does anyone know what I am doing wrong? Thank you very Much. >> >> Can you show what exactly you did? > The issue is that the first line of my input file: > > > > Causes the file to be read as an "xml application". Basically, I just > want to be able to use REXML to parse out this xml file, but it does not > parse properly with this line in the beginning of my input file. > (otherwise it works fine). Please provide the code you are using so others can try this out themselves. I asked for this already (see above). > I tried converting the files using iconv commands from your link, but it > UTF-16 and UTF-8, the same error occurs, without regard for format. > > Why is this line interfering with the parser and how would I fix it? > Thank you for your help. It seems there is no UTF-16 support: irb(main):009:0> f=File.open "x", "r:UTF-16" (irb):9: warning: Unsupported encoding UTF-16 ignored => # So there is no point in trying to import a UTF-16 encoded file in Ruby. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/