From: Gonzalo Rubio Date: 2006-02-01T04:18:22+09:00 Subject: XML, WebService and Character Encoding issue I created a Ruby proxy for a FoxPro app that needs to fetch data from a WebService (which returns it in XML) and read it in CSV format (for which i use REXML parser and output the CSV by hand) To do this the WebService returns me a Base64 encoded XML that i then decode and process. Everything works ok until you have non-standard characters in the XML data (non 7-bit characters, i.e. Western European accented characters) since the REXML parser dies complaining about a closing tag not found. I looked for an entities processor or a character encoding converter in the standard library and i coudn't find it. I ended doing an ugly hack by feeding a Hash with the accented character as the key, and the entity as the value, and then replacing back and forth the returned data. my function looks like this: def iso2entities(str, inverse) rep = Hash.new rep['叩'] = 'á' # ... snipped code ... rep['息'] = '©' unless inverse rep.each{|code, entity| str.gsub!(code, entity) } else rep.each{|code, entity| str.gsub!(entity, code) } end return str end It works, but feeding the Hash by hand is time consuming and code obviously looks like an ugly work-around... is there a "ruby standard" way to do it? -- Posted via http://www.ruby-forum.com/.