parameters: (f)
docstring: r"""
      >>> import io
      >>> s = 'abcd\uabcd'
      >>> enc = s.encode('utf-8')
      >>> enc
      b'abcd\xea\xaf\x8d'
      >>> n = bytes([len(enc)])  # little-endian 1-byte length
      >>> t = read_unicodestring1(io.BytesIO(n + enc + b'junk'))
      >>> s == t
      True
  
      >>> read_unicodestring1(io.BytesIO(n + enc[:-1]))
      Traceback (most recent call last):
      ...
      ValueError: expected 7 bytes in a unicodestring1, but only 6 remain
docstring_summary: r"""
      >>> import io
      >>> s = 'abcd\uabcd'
      >>> enc = s.encode('utf-8')
      >>> enc
      b'abcd\xea\xaf\x8d'
      >>> n = bytes([len(enc)])  # little-endian 1-byte length
      >>> t = read_unicodestring1(io.BytesIO(n + enc + b'junk'))
      >>> s == t
      True
docstring_tokens: r >>> import io >>> s = abcd \ uabcd >>> enc = s . encode ( utf - 8 ) >>> enc b abcd \ xea \ xaf \ x8d >>> n = bytes ( [ len ( enc ) ] ) # little - endian 1 - byte length >>> t = read_unicodestring1 ( io . BytesIO ( n + enc + b junk )) >>> s == t True
function: def read_unicodestring1(f):
      r"""
      >>> import io
      >>> s = 'abcd\uabcd'
      >>> enc = s.encode('utf-8')
      >>> enc
      b'abcd\xea\xaf\x8d'
      >>> n = bytes([len(enc)])  # little-endian 1-byte length
      >>> t = read_unicodestring1(io.BytesIO(n + enc + b'junk'))
      >>> s == t
      True
  
      >>> read_unicodestring1(io.BytesIO(n + enc[:-1]))
      Traceback (most recent call last):
      ...
      ValueError: expected 7 bytes in a unicodestring1, but only 6 remain
      """
  
      n = read_uint1(f)
      assert n >= 0
      data = f.read(n)
      if len(data) == n:
          return str(data, 'utf-8', 'surrogatepass')
      raise ValueError("expected %d bytes in a unicodestring1, but only %d "
                       "remain" % (n, len(data)))
function_tokens: def read_unicodestring1 ( f ) : n = read_uint1 ( f ) assert n >= 0 data = f . read ( n ) if len ( data ) == n : return str ( data , 'utf-8' , 'surrogatepass' ) raise ValueError ( "expected %d bytes in a unicodestring1, but only %d " "remain" % ( n , len ( data ) ) )