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?
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
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?
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
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