def auto_unicode(g, custom_unicodes={}):
    """
    Automatically set unicode value(s) for the specified glyph.

    The method uses RoboFab's ``glyph.autoUnicodes()`` function for common glyphs, and complements it with additional values from ``unicodes_extra``.

    """

    if g.name is not None:

        # handle 'uni' names
        if g.name[:3] == "uni" and len(g.name) == 7:
            c = g.name
            g.unicode = int(c.split('uni')[1], 16)

        # handle extra cases
        elif g.name in unicodes_extra.keys():
            uString = 'uni%s' % unicodes_extra[g.name]
            g.unicode = unicode_hexstr_to_int(uString)

        # use auto unicode for everything else
        elif custom_unicodes.get(g.name) is not None:
            uString = 'uni%s' % custom_unicodes[g.name]
            g.unicode = unicode_hexstr_to_int(uString)
        else:
            g.autoUnicodes()

        g.update()

#------------------------------
# unicode-to-string conversion
#------------------------------
# thanks Karsten Luecke, 2010
dataset/ETHPy150Open gferreira/hTools2/Lib/hTools2/modules/unicode.py/auto_unicode/original