\(gmail\) Alejandro Michelin Salomon
2009-Feb-20 14:14 UTC
Problem with special characters
> > I am using dbi to load data from database, to fill the rows. > > But the column 3 that is a description, is not fill when the > description has special characters like ??, ?, ??; >A wxRuby application can display any character of any script - but any string that''s passed into wxRuby must be UTF-8. I would guess that your database is using some 8-bit encoding like iso-8859-1. You should either: 1) convert your database to use utf-8 internally. This is the best solution if you''re able to design it from the start. 2) convert strings coming from the database to utf-8, using Ruby''s standard ''Iconv'' library, or, if you''re using Ruby 1.9, new string methods like "encode!". hth alex
(gmail) Alejandro Michelin Salomon
2009-Feb-20 20:27 UTC
[wxruby-users] RES: Problem with special characters
Alex : Thanks is working. I have a question descricao = Iconv.iconv( ''utf-8'', ''cp1252'', row[2] ); @grid.set_cell_value( contador, 2, descricao.to_s ); What i need make to_s to the result of Iconv.iconv? If i put descricao wihtout to_s the set_cell_value give error ?set_cell_value: can''t convert Array into String (TypeError)? Iconv.iconv returns array type? Thanks in advance De: wxruby-users-bounces at rubyforge.org [mailto:wxruby-users-bounces at rubyforge.org] Em nome de Alex Fenton Enviada em: sexta-feira, 20 de fevereiro de 2009 16:06 Para: General discussion of wxRuby Assunto: Re: [wxruby-users] Problem with special characters> > I am using dbi to load data from database, to fill the rows. > > But the column 3 that is a description, is not fill when the > description has special characters like ??, ?, ??; >A wxRuby application can display any character of any script - but any string that''s passed into wxRuby must be UTF-8. I would guess that your database is using some 8-bit encoding like iso-8859-1. You should either: 1) convert your database to use utf-8 internally. This is the best solution if you''re able to design it from the start. 2) convert strings coming from the database to utf-8, using Ruby''s standard ''Iconv'' library, or, if you''re using Ruby 1.9, new string methods like "encode!". hth alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users _____ avast! Antivirus <http://www.avast.com> : Inbound message clean. Virus Database (VPS): 090219-0, 19/02/2009 Tested on: 20/02/2009 16:45:44 avast! - copyright (c) 1988-2009 ALWIL Software. _____ avast! Antivirus <http://www.avast.com> : Outbound message clean. Virus Database (VPS): 090219-0, 19/02/2009 Tested on: 20/02/2009 17:27:11 avast! - copyright (c) 1988-2009 ALWIL Software. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20090220/595e54ea/attachment-0001.html>
On Fri, Feb 20, 2009 at 2:27 PM, (gmail) Alejandro Michelin Salomon < amichelins at gmail.com> wrote:> Alex : > > > > Thanks is working. > > > > I have a question > > > > descricao = Iconv.iconv( ''utf-8'', ''cp1252'', row[2] ); > > > > @grid.set_cell_value( contador, 2, descricao.to_s ); >The thing about Iconv.iconv() is that it always returns an array of strings, even if you just pass 1 string, so if your just passing 1 string, then you need to use @grid.set_cell_value( contador, 2, descricao[0]). hth, Mario -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20090220/79c2b5a0/attachment.html>
(gmail) Alejandro Michelin Salomon
2009-Feb-21 12:15 UTC
[wxruby-users] RES: RES: Problem with special characters
Mario : Works fine. Thanks a lot. De: wxruby-users-bounces at rubyforge.org [mailto:wxruby-users-bounces at rubyforge.org] Em nome de Mario Steele Enviada em: sexta-feira, 20 de fevereiro de 2009 23:29 Para: General discussion of wxRuby Assunto: Re: [wxruby-users] RES: Problem with special characters On Fri, Feb 20, 2009 at 2:27 PM, (gmail) Alejandro Michelin Salomon <amichelins at gmail.com> wrote: Alex : Thanks is working. I have a question descricao = Iconv.iconv( ''utf-8'', ''cp1252'', row[2] ); @grid.set_cell_value( contador, 2, descricao.to_s ); The thing about Iconv.iconv() is that it always returns an array of strings, even if you just pass 1 string, so if your just passing 1 string, then you need to use @grid.set_cell_value( contador, 2, descricao[0]). hth, Mario -- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ _____ avast! Antivirus <http://www.avast.com> : Inbound message clean. Virus Database (VPS): 090220-0, 20/02/2009 Tested on: 21/02/2009 09:02:31 avast! - copyright (c) 1988-2009 ALWIL Software. _____ avast! Antivirus <http://www.avast.com> : Outbound message clean. Virus Database (VPS): 090220-0, 20/02/2009 Tested on: 21/02/2009 09:15:26 avast! - copyright (c) 1988-2009 ALWIL Software. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20090221/1279b9ac/attachment.html>