code: def safe_unicode_stdin(string):
      
      if string is None:
          return None
      if is_bytes(string):
          if FROZEN:
              return string.decode("utf-8")
          try:
              return string.decode(sys.stdin.encoding)
          except UnicodeDecodeError:
              return string.decode(sys.stdin.encoding, "replace")
          except:
              return string.decode("utf-8")
      return string
docs: Safely convert the given string to a Unicode string,
      decoding using ``sys.stdin.encoding`` if needed.
  
      If running from a frozen binary, ``utf-8`` encoding is assumed.
  
      :param variant string: the byte string or Unicode string to convert
      :rtype: string