Unicode HOWTO?

I am disappointed about the (seeming) lack of Unicode support in Rails.
Is there a howto about working the most important limitations? For
example, figuring out the length of an entered word: “öüö”.length() will
return 6, not 3. So if there is a maximum number of characters a user is
allowed to enter, this won’t work as it should – it treats strings as
byte arrays instead of strings.

Is there an alternate string package that will treat Unicode Strings as
arrays of Characters instead of Bytes - no matter how many bytes are
used to encode a Character? Can anyone point me to a HOWTO or tutorial
or documentation for how to do this?

Visit -
http://wiki.rubyonrails.com/rails/pages/HowToUseUnicodeStrings
they link you to some nice libraries that might be helpful for you.
But yes, Rails isn’t that hot-show for unicode
Nice day,
Dor.

Roman H. wrote:

I am disappointed about the (seeming) lack of Unicode support in Rails.
Is there a howto about working the most important limitations? For
example, figuring out the length of an entered word: “öüö”.length() will
return 6, not 3. So if there is a maximum number of characters a user is
allowed to enter, this won’t work as it should – it treats strings as
byte arrays instead of strings.

Is there an alternate string package that will treat Unicode Strings as
arrays of Characters instead of Bytes - no matter how many bytes are
used to encode a Character? Can anyone point me to a HOWTO or tutorial
or documentation for how to do this?

Ã? usually do this with my applications and it works fine! Portuguese
Brasil.

class ApplicationController < ActionController::Base
before_filter :configure_charsets

def configure_charsets
if request.xhr?
@response.headers[“Content-Type”] ||= “text/javascript;
charset=iso-8859-1”
else
@response.headers[“Content-Type”] ||= “text/html;
charset=iso-8859-1”
end
end
end

“Funciona que é uma beleza! Abração!”

Roman H. wrote:

I am disappointed about the (seeming) lack of Unicode support in Rails.
Is there a howto about working the most important limitations? For
example, figuring out the length of an entered word: “öüö”.length() will
return 6, not 3. So if there is a maximum number of characters a user is
allowed to enter, this won’t work as it should – it treats strings as
byte arrays instead of strings.

Is there an alternate string package that will treat Unicode Strings as
arrays of Characters instead of Bytes - no matter how many bytes are
used to encode a Character? Can anyone point me to a HOWTO or tutorial
or documentation for how to do this?

Unicode support in Ruby does not exists.

I have been to a kind of workshop last week and Julik presented a kick
us presentation, you can check the plugin as a start
http://julik.nl/code/unicode-hacks/index.html

And send a an email to Matsumoto asking when we will have unicode
support in Ruby.

Good luck
Gokhan A.
www.sylow.net

On 26-jun-2006, at 0:50, Roman H. wrote:

Is there an alternate string package that will treat Unicode
Strings as
arrays of Characters instead of Bytes - no matter how many bytes are
used to encode a Character? Can anyone point me to a HOWTO or tutorial
or documentation for how to do this?

There is exactly such a package - it’s behaviour is a little unstable
now, because as soon as your diacritics
or parts of a ligature (of compound chars) cannot be normalised into
one codepoint it does what you don’t really expect.

Try unicode_hacks. We are trying to get them into Rails but as of
now I haven’t seen any interest on the part of the core.


Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl

Julian ‘Julik’ Tarkhanov skrev:

Try unicode_hacks. We are trying to get them into Rails but as of now
I haven’t seen any interest on the part of the core.

Apparently the use of unicode in an application is “application specific
behaviour”. The Rails core team take many good decisions but the
decision to not include unicode support in the core is just insane.
Everyone wanting to use unicode will do it more or less the same. Not
having it in the core is to break DRY on a universal level.

Yes, I know this can probably be done as a plugin. The problem with
plugins that will dig as deep into the core as a plugin like this will
probably break on every new version of the core so the plugin will
always lag behind the core versions (maybe not long but it will be
enough). If inside the core someone will have the responsibility to take
care of it before releasing a new version of the core. No?

/Marcus

ps. They (Rails core team) might have reconsidered to actually include
unicode support in Rails. If that is the case I take back what I said

Try unicode_hacks. We are trying to get them into Rails but as of
now I haven’t seen any interest on the part of the core.

Which one should we install?

or both? :slight_smile: And how do we install both? :slight_smile:

On 27-jun-2006, at 9:15, Dmitrii D. wrote:

Try unicode_hacks. We are trying to get them into Rails but as of
now I haven’t seen any interest on the part of the core.

Which one should we install?

The plugin is being updated all the time. The patch is more for the
rails-core to evaluate,
but we will eventually get to updating it as well.


Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl