Skip to content

Instantly share code, notes, and snippets.

@apavlyut
Created February 28, 2014 11:18
Show Gist options
  • Save apavlyut/9269390 to your computer and use it in GitHub Desktop.
Save apavlyut/9269390 to your computer and use it in GitHub Desktop.
# ruby 2.0
str = "\u0000\u0001\u000177773705257\u0000\u0000\u0001559#81635181\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\b\u0000\b\u0004!\u0004\"\u0004\u001E\u0004\u001F"
puts "str:\n"
puts str
puts "\n here relults for str:"
yes = str.force_encoding("utf-16be").encode("utf-8")
puts yes
puts yes.include?('СТОП')
puts str.force_encoding("utf-16le").encode("utf-8")
puts "\n"
puts "str2:\n"
str2 = "04210422041E041F"
puts str2
puts "\n here new relults for str2:"
puts "utf8:"
puts str2.force_encoding("utf-8")
puts "utf-16be:"
puts str2.force_encoding("utf-16be")
puts "utf-16be + utf-8:"
puts str2.force_encoding("utf-16be").encode("utf-8")
puts "utf-16le:"
puts str2.force_encoding("utf-16le")
puts "utf-16le + utf-8:"
puts str2.force_encoding("utf-16le").encode("utf-8")
str:
77773705257559#816351!"
here relults for str:
ķ㜷㜳㜰㔲㔷ĵ㔹⌸ㄶ㌵ СТОП
true
Ā㜁㜷㌷〷㈵㜵㔁㤵㠣㘱㔳㠱1ࠀࠀ℄∄Ḅἄ
str2:
04210422041E041F
here new relults for str2:
utf8:
04210422041E041F
utf-16be:
04210422041E041F
utf-16be + utf-8:
〴㈱〴㈲〴ㅅ〴ㅆ
utf-16le:
04210422041E041F
utf-16le + utf-8:
㐰ㄲ㐰㈲㐰䔱㐰䘱
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment