Skip to content

Instantly share code, notes, and snippets.

@shahoxo
Created March 25, 2013 03:46
Show Gist options
  • Save shahoxo/5234790 to your computer and use it in GitHub Desktop.
Save shahoxo/5234790 to your computer and use it in GitHub Desktop.
require 'iconv'
require 'kconv'
require 'nkf'
puts "---[UTF-8]---"
p slash1 = ["2f".hex].pack('c*')
p slash2 = ["c0".hex, "af".hex].pack('c*')
p slash3 = ["e0".hex, "80".hex, "af".hex].pack('c*')
p slash4 = ["f0".hex, "80".hex, "80".hex, "af".hex].pack('c*')
puts "\n---[Shift-JIS]@kconv---"
p slash1.tosjis
p slash2.tosjis
p slash3.tosjis
p slash4.tosjis
puts "\n---[Shift-JIS]@nkf---"
p NKF.nkf('-W -s', slash1)
p NKF.nkf('-W -s', slash2)
p NKF.nkf('-W -s', slash3)
p NKF.nkf('-W -s', slash4)
iconv = Iconv.new('SHIFT_JIS', 'UTF-8')
puts "\n---[Shift-JIS]@iconv---"
p iconv.iconv(slash1)
p iconv.iconv(slash2)
p iconv.iconv(slash3)
p iconv.iconv(slash4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment