Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Last active December 30, 2015 05:08
Show Gist options
  • Save tkfm-yamaguchi/7780231 to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/7780231 to your computer and use it in GitHub Desktop.
# coding: utf-8
require 'htmlentities'
coder = HTMLEntities.new
p coder.encode('Φ', :named) #=> 'Φ'
p coder.decode('φ') #=> 'φ'
# coding: utf-8
from html import entities
print('&%s;' % entities.codepoint2name[ord('Φ')]) #=> Φ
print(chr(entities.name2codepoint['phi'])) #=> φ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment