Skip to main content

UTF-16K

Unlimited UTF-16! UTF-16 ⊆ UTF-16K.

  • UTF-16K is a way to expand UTF-16 indefinitely without breaking UTF-16's existing syntax.
  • This repository contains a Python implementation of UTF-16K.
  • See UTF-8000-Website for the full writeup of UTF-8K and UTF-16K.
  • UTF-16K is in no way endorsed by or representative of the Unicode Consortium. This is a standalone project.

Installing

Available on PyPI as UTF-16K

Recommended install using pipx:

$ pipx install UTF-16K

provides

utf-16k(1)

with subcommands

utf-16k info
utf-16k encode
utf-16k decode

TLDR Examples

Using utf-16k info

utf-16k-info-example.png 1101101000111100 1101110000000000 1101101001110111 1101111010101101 ...

Color key:

  • Bright Yellow: UTF-16 surrogate frame 110110 (high) or 110111 (low)
  • Bright Red: upper 4 or 3 content bits of high surrogates, for UTF-16 the Unicode Plane indicator bits, for UTF-16K the bits '100' that indicate Planes 9 and 10
  • Bright Cyan: UTF-16K self-synchronization bit 0 or 1
  • Bright Magenta: UTF-16K self-punctuation bits 111...110
  • Bright Green: mandatory content bits (nb 4-word UTF-16K works slightly differently)
  • Green: content bits

Using utf-16k encode

$ echo 'U+DEADBEEFBADF00D' | utf-16k encode | hexdump -C
00000000  da 33 dd ea da 76 df ee  da 7e df ad da 7c dc 0d  |.3...v...~...|..|
00000010

Using utf-16k decode

Using the bytes from the encode example above

$ echo -ne '\xda\x33\xdd\xea\xda\x76\xdf\xee\xda\x7e\xdf\xad\xda\x7c\xdc\x0d' | utf-16k decode
U+DEADBEEFBADF00D |              | da33 ddea da76 dfee da7e dfad da7c dc0d | 1101101000110011 1101110111101010 ...

Package Contents

  • encode.py
    • encode(x: int) -> tuple[int]: Encode an unsigned integer in UTF-16K and return the words.
  • decode.py
    • UTF16KIncrementalDecoder: A 'fancy' incremental decoder class that can be fed words, and can be iterated over, yielding UTF16KInts when full code units have been supplied and decoded.
  • UTF16KInt.py
    • A wrapper around UTF16KWords that form a code unit.
  • UTF16KWord.py
    • UTF16KWord: a 'fancy' wrapper around UTF-16K words that is useful for education and inspection.
    • Various constants and utility functions.

See Also

Download files

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

Source Distribution

utf_16k-1.0.0.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

utf_16k-1.0.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file utf_16k-1.0.0.tar.gz.

File metadata

  • Download URL: utf_16k-1.0.0.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for utf_16k-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8e87c21d0a272c7d8fdd494833d2dc291e53c0fce29ab0afb28e0bcdc645fef4
MD5 6aad1c45f1093e2d92a4bc72453acbfb
BLAKE2b-256 a01f2a9e42c47d65cc704e90479f81cb1fd903f753c849454466760a68d663d6

See more details on using hashes here.

File details

Details for the file utf_16k-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: utf_16k-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for utf_16k-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fc77c5fc344811149938e3cb059641b17282023981607e9b37def28dd985c1f
MD5 32a467537b86c595ec575998dd8ae7b2
BLAKE2b-256 82f3532181cc7039c4b7bd90fb9a9017be6955308c50857333825bd681863298

See more details on using hashes here.

Release history Release notifications | RSS feed

3.3.0

2 files

This release

1.0.0 This release

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page