[Rails I18n] How to capitalize UTF8 string without downcasing
jmfaber at faberix.com
Thu Mar 20 10:15:46 EDT 2008
What is the best way to capitalize the first character of a UTF8 string?
String#capitalize downcases the rest of the string which is unacceptable
since there can be capitals in the middle of the string. ("see New
York".capitalize => "See new york"). Just picking off the first byte and
capitalizing that is also not an option since the first character can be
a multibyte UTF-8 character.
The only thing I can think of so far is either using Ruby 1.9 or the the
Rails multibyte Chars library to split off the first character and then
capitalize that and join it back together.
Surely there must be a better way for such a common problem?
Posted via http://www.ruby-forum.com/.
More information about the Railsi18n-discussion