code: def charspec_to_int(string):
      # Converts a character specification of the form 'A' or 'U+23BC'
      # to an integer
      if string.startswith("U+"):
          return int(string[2:], 16)
      elif len(string) == 1:
          return ord(string)
      else:
          raise Exception("Can't convert charspec: %r" % string)
  
imports: from collections import defaultdict
  import re
  from whoosh.compat import izip, u, iteritems, unichr, xrange
label_desc: Use image node_id 1 for calling a global function with example usage: charspec_to_int(string) and returns: int, ord