Watir tips and tricks
A collection of useful tips and tricks for WATIR and RUBY.
Home
Installation
Errors
Monday, September 19, 2011
Convert Unicode to UTF-8
Here is a simple function for changing \u3232 characters to UTF-8 characters in a given string:
def unicodeToUtf8(str)
return str.gsub(/\\u([a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9])/) {|p| [$1.to_i(16)].pack("U")}
end
No comments:
Post a Comment
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment