REXML::Document.new can we give encode parameters on this line?

后端 未结 1 1982
南方客
南方客 2021-01-27 17:18

doc = REXML::Document.new file My code is failing at this point whenever my xml file contains some special characters other than UTF-8 .

REXML::ParseException (         


        
1条回答
  •  花落未央
    2021-01-27 18:07

    You can call something like this

    REXML::Document.new(file.force_encoding("FILE_ENCODING").encode("UTF-8"))
    

    FILE_ENCODING is the encoding of your file variable.

    0 讨论(0)
提交回复
热议问题