parameters: (self, chars)
return_statement: return chars
docstring: Create a Unicode string
  
          If that fails, let Tcl try its best
docstring_summary: Create a Unicode string
docstring_tokens: Create a Unicode string
function: def decode(self, chars):
          """Create a Unicode string
  
          If that fails, let Tcl try its best
          """
          # Check presence of a UTF-8 signature first
          if chars.startswith(BOM_UTF8):
              try:
                  chars = chars[3:].decode("utf-8")
              except UnicodeError:
                  # has UTF-8 signature, but fails to decode...
                  return chars
              else:
                  # Indicates that this file originally had a BOM
                  self.fileencoding = BOM_UTF8
                  return chars
          # Next look for coding specification
          try:
              enc = coding_spec(chars)
          except LookupError as name:
              tkMessageBox.showerror(
                  title="Error loading the file",
                  message="The encoding '%s' is not known to this Python "\
                  "installation. The file may not display correctly" % name,
                  parent = self.text)
              enc = None
          if enc:
              try:
                  return unicode(chars, enc)
              except UnicodeError:
                  pass
          # If it is ASCII, we need not to record anything
          try:
              return unicode(chars, 'ascii')
          except UnicodeError:
              pass
          # Finally, try the locale's encoding. This is deprecated;
          # the user should declare a non-ASCII encoding
          try:
              chars = unicode(chars, encoding)
              self.fileencoding = encoding
          except UnicodeError:
              pass
          return chars
function_tokens: def decode ( self , chars ) : # Check presence of a UTF-8 signature first if chars . startswith ( BOM_UTF8 ) : try : chars = chars [ 3 : ] . decode ( "utf-8" ) except UnicodeError : # has UTF-8 signature, but fails to decode... return chars else : # Indicates that this file originally had a BOM self . fileencoding = BOM_UTF8 return chars # Next look for coding specification try : enc = coding_spec ( chars ) except LookupError as name : tkMessageBox . showerror ( title = "Error loading the file" , message = "The encoding '%s' is not known to this Python " "installation. The file may not display correctly" % name , parent = self . text ) enc = None if enc : try : return unicode ( chars , enc ) except UnicodeError : pass # If it is ASCII, we need not to record anything try : return unicode ( chars , 'ascii' ) except UnicodeError : pass # Finally, try the locale's encoding. This is deprecated; # the user should declare a non-ASCII encoding try : chars = unicode ( chars , encoding ) self . fileencoding = encoding except UnicodeError : pass return chars