Ruby and unicode


#1

Does Ruby support unicode? If not it’s a disappointment.


#2

Well, there are extension libraries for handling unicodes. It is
also expected that Ruby 2.0 will bring more complete I18N supports.

What are your needs?

daesan

On May 25, 2006, at 3:05 AM, Pål Bergström wrote:

Does Ruby support unicode? If not it’s a disappointment.


Posted via http://www.ruby-forum.com/.

Dae San H.
removed_email_address@domain.invalid


#3

Dae San H. wrote:

Well, there are extension libraries for handling unicodes. It is
also expected that Ruby 2.0 will bring more complete I18N supports.

What are your needs?

daesan

On May 25, 2006, at 3:05 AM, Pål Bergström wrote:

Does Ruby support unicode? If not it’s a disappointment.


Posted via http://www.ruby-forum.com/.

Dae San H.
removed_email_address@domain.invalid

Just to be able to work smoothly from source to browser in Swedish
without problems, the beauty of unicode. As I can understand it works
like php, where certain methods like string lengths can give problems,
but besides that it just passes it through. Is this correct?


#4

On 5/24/06, Pål Bergström removed_email_address@domain.invalid wrote:

Just to be able to work smoothly from source to browser in Swedish
without problems, the beauty of unicode.

Pål, you don’t have to use unicode to work in swedish. ISO-8859-1 will
be sufficient to get accented characters including åäö. ISO-8859-1 is
handled by Ruby without any problems.

If your are working in Rails, please see the swedish Rails user group
wiki for details:

http://rails.se/rails/show/Railstips+för+svenska+applikationer

Regards,

Peter


#5

On 24.5.2006, at 23:02, Dae San H. wrote:

If you need methods that properly manipulate UTF8 strings, install
unicode gem and install unicode hacks from http://
julik.textdriven.com/svn/tools/rails_plugins/unicode_hacks/

Unicode hacks replaces String methods with UTF8 aware versions.

You should not advise the use of unicode hacks plugin, since it will
very probably break any Rails application.

See for example http://www.fngtps.com/2006/01/encoding-in-rails and
http://redhanded.hobix.com/inspect/unicodeLibForRuby18.html

Regards,

izidor


#6

Right, that is because Rails depend on many of String methods that
unicode_hacks replaces.

However, you can just rename the method names in unicode_hacks. I
just add ‘u_’ prefix to all the methods in unicode_hacks.

Cheers,
Daesan

On May 27, 2006, at 1:38 AM, Izidor J. wrote:

You should not advise the use of unicode hacks plugin, since it

Dae San H.
removed_email_address@domain.invalid


#7

Yes, strings in UTF8 (or any character set for that matter) simply
pass through since they are just byte sequence.

If you need methods that properly manipulate UTF8 strings, install
unicode gem and install unicode hacks from http://
julik.textdriven.com/svn/tools/rails_plugins/unicode_hacks/

Unicode hacks replaces String methods with UTF8 aware versions.

You would also need to put following code snippet in config/
environment.rb:

$KCODE = ‘u’

http://wiki.rubyonrails.com/rails/pages/HowToUseUnicodeStrings is a
good resource for unicode usage on rails.

daesan

On May 25, 2006, at 4:20 AM, Pål Bergström wrote:

Just to be able to work smoothly from source to browser in Swedish
without problems, the beauty of unicode. As I can understand it works
like php, where certain methods like string lengths can give problems,
but besides that it just passes it through. Is this correct?

Dae San H.
removed_email_address@domain.invalid