[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Problem with special characters

Jean-Denis Muys

2/20/2009 2:06:00 PM


> From: Alejandro Michelin salomon <amichelins@gmail.com>
> Reply-To: <ruby-talk@ruby-lang.org>
> Newsgroups: comp.lang.ruby
> Date: Thu, 19 Feb 2009 22:04:38 +0900
> To: ruby-talk ML <ruby-talk@ruby-lang.org>
> Subject: Problem with special characters
>=20
> Hi:
>=20
> O.S Windows XP sp3
> Ruby 1.8.6
>=20
> I am working with ruby using DBI::Mysql, and the returned descriptions
> are not displayed ok. The puts command is displaying wrong characters,
> when the text has special chars like =E1.
>=20
[snip]
>=20
> How to display the text with special characters like '=E7 =FA =ED' tha are
> used commonly in latin languages?
> --=20
> Posted via http://www.ruby-....
>=20

I am facing a similar issue on Mac OS X where the TextMate console can only
use UTF8 encoding (The Mac terminal can be set to any encoding).

I asked a similar question to the TextMate mailing list, and I got a useabl=
e
workaround. Here is a very small program reading and printing the content o=
f
a text file encoded in ISO-8859-1:

require "iconv"

file =3D File.open("test.txt", "r")
file.each {
|line|
print line
print Iconv.iconv("UTF-8","LATIN1",line)
}
file.close

So I guess you can use the iconv library to convert in whichever direction
you may need.

Regards,

JD