Problem with special characters

  • Thread starter Alejandro Michelin salomon
  • Start date
A

Alejandro Michelin salomon

Hi:

O.S Windows XP sp3
Ruby 1.8.6

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 á.

My program here :

puts "Olá Mundo!"; # for test

require "dbi";

begin
# connect to the MySQL server
dbh = DBI.connect("DBI:Mysql:test:localhost", "test",
"q3der3fe5ahy");

sth = dbh.execute("SELECT * FROM uf ");

sth.each do |row|
puts 'ID:' + row[0].to_s + ' Mi: ' + row[1] + 'Decrição: ' +
row[2];
end
sth.finish;
rescue DBI::DatabaseError => e
puts "An error occurred";
puts "Error code: #{e.err}";
puts "Error message: #{e.errstr}";
ensure
# disconnect from server
dbh.disconnect if dbh;
end

//=========== Result
Olß Mundo!
ID:1 Mi: AC DecriþÒo: Acre
ID:2 Mi: AL DecriþÒo: Alagoas
ID:3 Mi: AM DecriþÒo: Amazonas
ID:4 Mi: AP DecriþÒo: Amapß
ID:5 Mi: BA DecriþÒo: Bahia
ID:6 Mi: CE DecriþÒo: Cearß
ID:7 Mi: DF DecriþÒo: Distrito Federal
ID:8 Mi: ES DecriþÒo: EspÃrito Santo
ID:9 Mi: GO DecriþÒo: Goißs
ID:10 Mi: MA DecriþÒo: MaranhÒo
ID:11 Mi: MG DecriþÒo: Minas Gerais
ID:12 Mi: MS DecriþÒo: Mato Grosso do Sul
ID:13 Mi: MT DecriþÒo: Mato Grosso
ID:14 Mi: PA DecriþÒo: Parß
ID:15 Mi: PB DecriþÒo: ParaÃba
ID:16 Mi: PE DecriþÒo: Pernambuco
ID:17 Mi: PI DecriþÒo: PiauÃ
ID:18 Mi: PR DecriþÒo: Paranß
ID:19 Mi: RJ DecriþÒo: Rio de Janeiro
ID:20 Mi: RN DecriþÒo: Rio Grande do Norte
ID:21 Mi: RO DecriþÒo: Rond¶nia
ID:22 Mi: RR DecriþÒo: Roraima
ID:23 Mi: RS DecriþÒo: Rio Grande do Sul
ID:24 Mi: SC DecriþÒo: Santa Catarina
ID:25 Mi: SE DecriþÒo: Sergipe
ID:26 Mi: SP DecriþÒo: SÒo Paulo
ID:27 Mi: TO DecriþÒo: Tocantins
ID:28 Mi: XX DecriþÒo: Fora Do Brasil

How to display the text with special characters like 'ç ú í' tha are
used commonly in latin languages?
 

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top