parameters: (text)
return_statement: return t
docstring: Remove weird formats in texts and wipes UTF characters.
  
      It removes `{}`, html codes, \\(U...) characters,
      and decodes the string as utf8 or latin1 if needed.
      For Python 3 there is no decoding needed.
  
      Parameters
      ----------
      text : str
          The input string.
  
      Results
      -------
      str
          The deformatted string.
docstring_summary: Remove weird formats in texts and wipes UTF characters.
docstring_tokens: Remove weird formats in texts and wipes UTF characters .
function: def deformat(text):
      """Remove weird formats in texts and wipes UTF characters.
  
      It removes `{}`, html codes, \\(U...) characters,
      and decodes the string as utf8 or latin1 if needed.
      For Python 3 there is no decoding needed.
  
      Parameters
      ----------
      text : str
          The input string.
  
      Results
      -------
      str
          The deformatted string.
      """
      # remove ACAD string formatation
      # t = re.sub('{([^!}]([^}]|\n)*)}', '', text)
      # print("input text: ",text)
      t = text.strip("{}")
      t = re.sub("\\\.*?;", "", t)
      # replace UTF codes by utf chars
      sts = re.split("\\\\(U\+....)", t)
      ns = u""
      for ss in sts:
          # print(ss, type(ss))
          if ss.startswith("U+"):
              ucode = "0x" + ss[2:]
              # In Python3 unichr doesn't exist anymore
              ns += six.unichr(eval(ucode))
          else:
              try:
                  ns += ss.decode("utf8")
              except UnicodeError:
                  try:
                      ns += ss.decode("latin1")
                  except UnicodeError:
                      print("unable to decode text: ", text)
              except AttributeError:
                  # this is python3 (nothing to do)
                  ns += ss
      t = ns
      # replace degrees, diameters chars
      t = re.sub('%%d', u'°', t)
      t = re.sub('%%c', u'Ø', t)
      t = re.sub('%%D', u'°', t)
      t = re.sub('%%C', u'Ø', t)
      # print("output text: ", t)
      return t
function_tokens: def deformat ( text ) : # remove ACAD string formatation # t = re.sub('{([^!}]([^}]|\n)*)}', '', text) # print("input text: ",text) t = text . strip ( "{}" ) t = re . sub ( "\\\.*?;" , "" , t ) # replace UTF codes by utf chars sts = re . split ( "\\\\(U\+....)" , t ) ns = u"" for ss in sts : # print(ss, type(ss)) if ss . startswith ( "U+" ) : ucode = "0x" + ss [ 2 : ] # In Python3 unichr doesn't exist anymore ns += six . unichr ( eval ( ucode ) ) else : try : ns += ss . decode ( "utf8" ) except UnicodeError : try : ns += ss . decode ( "latin1" ) except UnicodeError : print ( "unable to decode text: " , text ) except AttributeError : # this is python3 (nothing to do) ns += ss t = ns # replace degrees, diameters chars t = re . sub ( '%%d' , u'°', ) t = re . sub ( '%%c' , u'Ø', ) t = re . sub ( '%%D' , u'°', ) t = re . sub ( '%%C' , u'Ø', ) # print("output text: ", t) return t