The solution is to use .ord.to_s(16)
Examples:
Getting unicode value of string:
Examples:
'♥'.ord.to_s(16) = 2665 '$'.ord.to_s(16) = 24 '€'.ord.to_s(16) = 20ac 'a'.ord.to_s(16) = 61
Getting unicode value of string:
'my string'.each_char.map{|c| c.ord.to_s(16)}.join
No comments:
Post a Comment