Skip to content

Instantly share code, notes, and snippets.

@heathd
Created December 11, 2012 14:57
Show Gist options
  • Save heathd/4259115 to your computer and use it in GitHub Desktop.
Save heathd/4259115 to your computer and use it in GitHub Desktop.
All possible double-encodings of Windows-1252
class CodePoint
def initialize(b)
@b = b
end
def hex
@b.to_s(16)
end
def char_windows
@b.chr.force_encoding("Windows-1252")
end
def char_utf8
char_windows.encode("utf-8") rescue nil
end
def double_encoded
char_utf8.force_encoding("Windows-1252").encode("utf-8") rescue nil
end
end
puts (128..255).map {|b| CodePoint.new(b)}.map { |c| "#{c.hex}: #{c.char_utf8 || " "} => #{c.double_encoded}" }.join("\n")
80: € => €
81: =>
82: ‚ => ‚
83: ƒ => Æ’
84: „ => „
85: … => …
86: † => †
87: ‡ => ‡
88: ˆ => ˆ
89: ‰ => ‰
8a: Š => Å 
8b: ‹ => ‹
8c: Œ => Å’
8d: =>
8e: Ž => Ž
8f: =>
90: =>
91: ‘ => ‘
92: ’ => ’
93: “ => “
94: ” =>
95: • => •
96: – => –
97: — => —
98: ˜ => Ëœ
99: ™ => â„¢
9a: š => Å¡
9b: › => ›
9c: œ => Å“
9d: =>
9e: ž => ž
9f: Ÿ => Ÿ
a0:   =>  
a1: ¡ => ¡
a2: ¢ => ¢
a3: £ => £
a4: ¤ => ¤
a5: ¥ => Â¥
a6: ¦ => ¦
a7: § => §
a8: ¨ => ¨
a9: © => ©
aa: ª => ª
ab: « => «
ac: ¬ => ¬
ad: ­ => ­
ae: ® => ®
af: ¯ => ¯
b0: ° => °
b1: ± => ±
b2: ² => ²
b3: ³ => ³
b4: ´ => ´
b5: µ => µ
b6: ¶ => ¶
b7: · => ·
b8: ¸ => ¸
b9: ¹ => ¹
ba: º => º
bb: » => »
bc: ¼ => ¼
bd: ½ => ½
be: ¾ => ¾
bf: ¿ => ¿
c0: À => À
c1: Á =>
c2:  => Â
c3: à => Ã
c4: Ä => Ä
c5: Å => Ã…
c6: Æ => Æ
c7: Ç => Ç
c8: È => È
c9: É => É
ca: Ê => Ê
cb: Ë => Ë
cc: Ì => ÃŒ
cd: Í =>
ce: Î => ÃŽ
cf: Ï =>
d0: Ð =>
d1: Ñ => Ñ
d2: Ò => Ã’
d3: Ó => Ó
d4: Ô => Ô
d5: Õ => Õ
d6: Ö => Ö
d7: × => ×
d8: Ø => Ø
d9: ٠=> Ù
da: Ú => Ú
db: Û => Û
dc: Ü => Ãœ
dd: Ý =>
de: Þ => Þ
df: ß => ß
e0: à => à
e1: á => á
e2: â => â
e3: ã => ã
e4: ä => ä
e5: å => Ã¥
e6: æ => æ
e7: ç => ç
e8: è => è
e9: é => é
ea: ê => ê
eb: ë => ë
ec: ì => ì
ed: í => í
ee: î => î
ef: ï => ï
f0: ð => ð
f1: ñ => ñ
f2: ò => ò
f3: ó => ó
f4: ô => ô
f5: õ => õ
f6: ö => ö
f7: ÷ => ÷
f8: ø => ø
f9: ù => ù
fa: ú => ú
fb: û => û
fc: ü => ü
fd: ý => ý
fe: þ => þ
ff: ÿ => ÿ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment