Unicode substrings in Ruby 1.8.x

October 15, 2010 by Michael

Here is how to get correct unicode substrings in Ruby 1.8.x

require 'jcode'
$KCODE = 'u'
 
"öäüÖÄÜß".split(//)[4,2].join
# ÄÜ

Don’t know, if this performes well… In case you have better ideas, please drop me a comment.

No comments yet

Post a Comment

Your email is never published nor shared. Required fields are marked *