0

I'm trying to display pieces of text in multiple languages. Because they're all European languages i've chosen to stick with UTF-8 encoding for the database and the sources of the data. The Database is MySQL and setup with UTF-8 encoding.

When looking at the configuration of my RoR project, I can find various settings that tell it to do everything in UTF-8 encoding. The data I've stored in the database comes from an XML file that has the UTF-8 encoding attribute and is created with notepad++ and saved with UTF-8 encoding.

When I retrieve the data from the database however, the output is text withs everal � entities in it. I'm clueless on how to solve this problem.... Below is my environment setup:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.5.2
  - RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]
  - INSTALLATION DIRECTORY: c:/Ruby/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: c:/Ruby/bin/ruby.exe
  - EXECUTABLE DIRECTORY: c:/Ruby/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - c:/Ruby/lib/ruby/gems/1.8
     - c:/Users/arne.de.herdt.TENFORCE2/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

If there's anything else needed of info, please ask and i'll update this topic. I'm just trying to get the data to be displayed properly.

EXAMPLE: Prüfer f�r die Zerst�rungsfreie Werkstoffpr�fung (m/w) Arbeitsort:D�sseldorf

EDIT: Adding the database.yml file output

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
#   gem install mysql2
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: ESCO_development
  pool: 5
  username: hidden_username
  password: hidden_password
  host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: ESCO_test
  pool: 5
  username: hidden_username
  password: hidden
  host: localhost

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: ESCO_production
  pool: 5
  username: hidden_username
  password: hidden
  host: localhost
4
  • Did you indicate the db connection to be UTF-8? Commented Jun 3, 2011 at 14:54
  • yes i have. I's inside the database.yml file. Check the original post for information Commented Jun 3, 2011 at 15:04
  • Are you sure your database and tables are created with the right character encoding and collation? (show create database and show create table will help you to get this information.) If you used a ruby program to insert your data from your xml files into the database did you ran it with -Ku ? Commented Jun 3, 2011 at 15:27
  • i've written a class that interprets the xml and this is triggered from rake db:seed, i'll try adding the flags as you mentioned Commented Jun 5, 2011 at 8:00

1 Answer 1

1

All your database configuration seems fine, did you check if your browser isn't forcing any charset encoding? Try changing the charset manually in your browser.

Also, check your html files to find any other charset encoding that isn't utf8

Sign up to request clarification or add additional context in comments.

2 Comments

browser is set to UTF8, checked the application.rb and environment.rb, not headers beeing set in any of the views
found the issue. The wrong encoding was indeed forced on by the browser settings. Disabled it and all worked fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.