# -*- coding: utf-8 -*-
from htmlentitydefs import codepoint2name

def unicode2htmlentities(u):

    htmlentities = list()

    for c in u:
        if ord(c) < 128:
            htmlentities.append(c)
        else:
	    try:
                htmlentities.append('&%s;' % codepoint2name[ord(c)])
            except:
                htmlentities.append('&#%d;' % ord(c))
    return ''.join(htmlentities)

import sys
fp = open(sys.argv[1])
print unicode2htmlentities(fp.read().decode('utf-8'))
fp.close()

