Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Problem with encoding latin1/UTF8
Mark Toth
12/28/2007 10:16:00 PM
I have a database with latin1_swedish_ci encoding.
In my database.yml file there is:
development:
adapter: mysql
encoding: latin1
When I import data to the database it will store it correctly, but when
I´m reading it from the databse I get ��� instead of åäö.
I´m using the following code to read from the databse:
@results = Product.find(:all, :conditions => [ "sku LIKE ?",
a1+@searchstring+a2], :limit => 50)
Any idea? I´ve tried to set the $KCODE = 'latin1' without success.
--
Posted via
http://www.ruby-...
.
1 Answer
Chris Gers32
1/7/2008 8:39:00 AM
0
Hi Mark,
I'm not sure the problems are related, but I've had to convert data from
an Oracle database with Win-1252 encoding to UTF-8 for generating
OpenOffice files. For that, I used the following syntax (being new to
Ruby/Rails, I still prefer plain SQL queries...):
@wrk_vpreparations = WrkVpreparation.find_by_sql(
["SELECT CONVERT( CODE, 'UTF8', 'WE8MSWIN1252' ) AS CODE,
CONVERT( DESC_FR, 'UTF8', 'WE8MSWIN1252' ) AS
DESCRIPTION
FROM WRK_VPREPARATIONS
WHERE ID=?", params[:id]] )
Hope this helps.
Chris.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Problem with encoding latin1/UTF8
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password