0

i currently try to import some XML via XMLSimple in my RoR-3 App.

on 1 position, that XML stores a YAML-Structure. Dont slap me, i did not create the xml ;)

now that i have it stored in a variable, lets say yamldata, i want to parse its content.

so i do:

chunks = YAML::load yamldata

and thats pretty it.

when i now echo these chunks-values to console, it get this:

  • Bülach vert

what i wanted to have is:

  • Bülach vert

when i use exact same sourcecode in IRB, i actually get this 'ü' instead of 'ü'.

i really dont know what to do here.


my Gemfile:

cat Gemfile

source 'http://rubygems.org'

gem 'rails', '3.1.0'
gem 'mysql2'
gem 'haml'
gem 'activerecord', :require => "active_record"
gem 'xml-simple'
gem 'hpricot'

ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

i`d be happy with any idea.

Note: i echo these values before!! i store them into a model, so i guess that its not a sql-related issue - however, db-encoding is utf8 too.

any idea? Thanks!

thanks to the helpers! :)

Community
  • 1
  • 1
thedanielhanke
  • 730
  • 1
  • 6
  • 22

2 Answers2

3

i found that irb does use Syck, rails Psych. so i guess this is the main difference... will research more..

SOLUTION:

 require 'yaml'
 YAML::ENGINE.yamler= 'syck'

into boot.rb and BAM!

Community
  • 1
  • 1
thedanielhanke
  • 730
  • 1
  • 6
  • 22
0

Maybe this answer can help you:

Ruby on Rails 3, incompatible character encodings: UTF-8 and ASCII-8BIT with i18n

He states that he could solve a similar problem by configuring this:

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

on config/environment.rb

Hope that helps.

Community
  • 1
  • 1
martincho
  • 4,517
  • 7
  • 32
  • 42
  • thanks for that hint - good to know that. unfortunately it did not solve the problem. i pleaced it in environment.rb + executed it in console too, very same result. :/ – thedanielhanke Sep 13 '11 at 22:50