Using jcode you can make regular expressions UTF-8 aware : KCODE « Development « Ruby






Using jcode you can make regular expressions UTF-8 aware


$KCODE = 'u'
require 'jcode'

class String
  def reverse
    scan(/./).reverse.join
  end
end

puts "asd".reverse

 








Related examples in the same category

1.Setting the $KCODE global variable to 'u' and loading jcode gives regular expressions awareness of UTF-8 characters
2.$KCODE Demo
3.$KCODE = 'u'
4.Handling International Encodings
5.Check string size for non ascii code
6.Count non-ascii string
7.Length of non-ascii string