These problems are present in any String
method that expects each character of a string to be a single byte, such as String#count,
String#slice, and so on. Fortunately, Active Support includes a module called Multibyte,
which adds a chars accessor to the String class, on which you can safely perform these operations
on multibyte (Unicode) strings. Therefore, instead of calling "hello".slice, you can
safely call "hello".chars.slice. For more information about ActiveSupport::Multibyte, read
the API documents for the chars method at
http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/
Unicode.html#M000417
?– Note The authors of Ruby have said that Ruby will get full Unicode support in Ruby 1.9 and 2.0, so
hopefully, internationalization will be less of a problem.
Finally, it is likely necessary to provide translations for the messages displayed to users in
your programs. There are several plug-ins available to assist with internationalization and localization.
One of the simplest is the Localization plug-in, written by Thomas Fuchs.
Pages:
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469