Prev | Current Page 379 | Next

Brad Ediger

"Advanced Rails"

length # => 4
cafe_utf8.length # => 5
JavaScript URI encoding and UTF-8
There is one important thing to remember if you use JavaScript to URI-encode text
in a UTF-8 environment: always encode data using encodeURI( ) or
encodeURIComponent( ); do not use escape( ). The encodeURI forms follow RFC 3986,
converting the text to UTF-8 and percent-encoding each byte. This makes things
much easier on the server end.
The escape( ) function, on the other hand, escapes one character at a time, using
nonstandard constructs such as %u1234 (corresponding to the code point U+1234). It
escapes extended-ASCII characters as Latin-1, even on a page served as UTF-8:
250 | Chapter 8: i18n and L10n
>>> document.characterSet
"UTF-8"
>>> escape("caf?©")
"caf%E9"
>>> encodeURI("caf?©")
"caf%C3%A9"
Rails L10n
For an application to be truly ready for worldwide visitors, internationalization is just
the beginning. It is vital for an application with global reach to correctly accept, process,
and store UTF-8 data. But it is also important, when supporting users from different
regions and locales, to localize the interface and any applicable data to the users??™
locales. This can involve any of several things, which we will cover in this section.
Interface/Resource Translation
The way the term ???localization??? is most often used, it refers to translating interface
text and resources into users??™ languages.


Pages:
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391