Skip to main content

UTF-7 encoded unsigned integer

Project description

Encoder/decoder of an UTF-7 encoded unsigned integer.

>>> utf7.pack_bytes(65535)
b'\xff\xff\x03'
>>> utf7.unpack_bytes(b'\xff\xff\x03')
65535

UTF-7 uint is used for BinaryWriter.Write(String) in Microsoft .NET Framework. Here’s an example of ping-pong between Python server and C# client:

while not socket.closed:
    # recv ping
    ping_size = utf7.unpack_socket(socket)
    ping_data = socket.recv(ping_size)
    assert ping_data == b'ping'
    # send pong
    pong_data = b'pong'
    pong_size = len(pong_data)
    utf7.pack_socket(pong_size, socket)
    socket.send(pong_data)

You can also use _utf7 written in C to take high-speed:

import _utf7 as utf7

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utf7-0.9.3.tar.gz (20.6 kB view details)

Uploaded Source

File details

Details for the file utf7-0.9.3.tar.gz.

File metadata

  • Download URL: utf7-0.9.3.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for utf7-0.9.3.tar.gz
Algorithm Hash digest
SHA256 f1a46808b4e44cf9208d78ce696f5c3ead44b6fdcc79db00460ec6b6603979dc
MD5 767fa284d5acd1efc411bfc26a1e8f64
BLAKE2b-256 5fad39684ee5e55d846f7a3b6ad698b4fd8fbc72c077dd61aa9543499c628d20

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page