Unicodeのハイフンっぽい文字いろいろ

全角ハイフンを半角に変換する処理ではまったので。同じに見える字形で違うコードを指してた。

#!/usr/bin/ruby 

# 'HYPHEN-MINUS' (U+002D)
# http://www.fileformat.info/info/unicode/char/002d/index.htm
puts "\x2D"

# 'MINUS SIGN' (U+2212)
# http://www.fileformat.info/info/unicode/char/2212/index.htm
puts "\xE2\x88\x92"

# 'FULLWIDTH HYPHEN-MINUS' (U+FF0D)
# http://www.fileformat.info/info/unicode/char/ff0d/index.htm
puts "\xEF\xBC\x8D"

# 'KATAKANA-HIRAGANA PROLONGED SOUND MARK' (U+30FC)
# http://www.fileformat.info/info/unicode/char/30fc/index.htm
puts "\xE3\x83\xBC"

# 'FIGURE DASH' (U+2012)
# http://www.fileformat.info/info/unicode/char/2012/index.htm
puts "\xE2\x80\x92"

# 'EN DASH' (U+2013)
# http://www.fileformat.info/info/unicode/char/2013/index.htm
puts "\xE2\x80\x93"

# 'EM DASH' (U+2014)
# http://www.fileformat.info/info/unicode/char/2014/index.htm
puts "\xE2\x80\x94"

# 'HORIZONTAL BAR' (U+2015)
# http://www.fileformat.info/info/unicode/char/2015/index.htm
puts "\xE2\x80\x95"

# 'BOX DRAWINGS LIGHT HORIZONTAL' (U+2500)
# http://www.fileformat.info/info/unicode/char/2500/index.htm
puts "\xE2\x94\x80"

上から順に。

  • -