Skip to main content

Fast MUTF-8 encoder & decoder

Project description

Tests

mutf-8

This package contains simple pure-python as well as C encoders and decoders for the MUTF-8 character encoding. In most cases, you can also parse the even-rarer CESU-8.

These days, you'll most likely encounter MUTF-8 when working on files or protocols related to the JVM. Strings in a Java .class file are encoded using MUTF-8, strings passed by the JNI, as well as strings exported by the object serializer.

This library was extracted from Lawu, a Python library for working with JVM class files.

🎉 Installation

Install the package from PyPi:

pip install amulet-mutf8

Binary wheels are available for the following:

py3.6 py3.7 py3.8 py3.9
OS X (x86_64) y y y y
Windows (x86_64) y y y y
Linux (x86_64) y y y y

If binary wheels are not available, it will attempt to build the C extension from source with any C99 compiler. If it could not build, it will fall back to a pure-python version.

Usage

Encoding and decoding is simple:

from mutf8 import encode_modified_utf8, decode_modified_utf8

unicode = decode_modified_utf8(byte_like_object)
bytes = encode_modified_utf8(unicode)

This module does not register itself globally as a codec, since importing should be side-effect-free.

📈 Benchmarks

The C extension is significantly faster - often 20x to 40x faster.

MUTF-8 Decoding

Name Min (μs) Max (μs) StdDev Ops
cmutf8-decode_modified_utf8 0.00009 0.00080 0.00000 9957678.56358
pymutf8-decode_modified_utf8 0.00190 0.06040 0.00000 450455.96019

MUTF-8 Encoding

Name Min (μs) Max (μs) StdDev Ops
cmutf8-encode_modified_utf8 0.00008 0.00151 0.00000 11897361.05101
pymutf8-encode_modified_utf8 0.00180 0.16650 0.00000 474390.98091

C Extension

The C extension is optional. If a binary package is not available, or a C compiler is not present, the pure-python version will be used instead. If you want to ensure you're using the C version, import it directly:

from mutf8.cmutf8 import decode_modified_utf8

decode_modified_utf(b'\xED\xA1\x80\xED\xB0\x80')

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

amulet_mutf8-1.0.7.tar.gz (8.9 kB view details)

Uploaded Source

Built Distributions

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

amulet_mutf8-1.0.7-cp314-cp314-win_arm64.whl (10.9 kB view details)

Uploaded CPython 3.14Windows ARM64

amulet_mutf8-1.0.7-cp314-cp314-win_amd64.whl (12.1 kB view details)

Uploaded CPython 3.14Windows x86-64

amulet_mutf8-1.0.7-cp314-cp314-macosx_10_15_universal2.whl (12.7 kB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

amulet_mutf8-1.0.7-cp313-cp313-win_arm64.whl (10.8 kB view details)

Uploaded CPython 3.13Windows ARM64

amulet_mutf8-1.0.7-cp313-cp313-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.13Windows x86-64

amulet_mutf8-1.0.7-cp313-cp313-macosx_10_13_universal2.whl (12.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

amulet_mutf8-1.0.7-cp312-cp312-win_arm64.whl (10.8 kB view details)

Uploaded CPython 3.12Windows ARM64

amulet_mutf8-1.0.7-cp312-cp312-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.12Windows x86-64

amulet_mutf8-1.0.7-cp312-cp312-macosx_10_13_universal2.whl (12.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

amulet_mutf8-1.0.7-cp311-cp311-win_arm64.whl (10.8 kB view details)

Uploaded CPython 3.11Windows ARM64

amulet_mutf8-1.0.7-cp311-cp311-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.11Windows x86-64

amulet_mutf8-1.0.7-cp311-cp311-macosx_10_9_universal2.whl (12.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file amulet_mutf8-1.0.7.tar.gz.

File metadata

  • Download URL: amulet_mutf8-1.0.7.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for amulet_mutf8-1.0.7.tar.gz
Algorithm Hash digest
SHA256 7e45b1bdfdc33e3bcd8e986956de7a5a404a631937ffb45b87c686b61614bf7f
MD5 d1e0774ff1abdb7c9250a039b7d2ab97
BLAKE2b-256 300cb49bed3ea8ccfc9956d76c422d31ba1bfaf4a0320e6ea9e02dac91f64869

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp314-cp314-win_arm64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp314-cp314-win_arm64.whl
Algorithm Hash digest
SHA256 9b0bac5dd4f137e3970f65bc8d30f3047552759adf5049ef532d15ffeb509459
MD5 6b39ae17214b0875e41a5ed059aadb99
BLAKE2b-256 f0c836a4aa9136b0147ae65c3cd514f69250f2346aa2aa26389ecbe7be4dc6a4

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 e8c92db39c6be1c82331aa13a2694355fb5735769603aa6dc1f5748daf1bfe5d
MD5 343ccc03c61fb9f89dcfe1a15ad5bfab
BLAKE2b-256 b149d3af34f0baa54c810765adb94e08b21f90e335ab4275ce2e9923511ff20e

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 f2eb89ae4c1fc8d8c237452b9bf2fb674c1a38ba9e59f363fe719d9693058a3f
MD5 7c8807fd5af9db08a97db418ffae1c6c
BLAKE2b-256 f19d1d8a2f992b8eb97bf66e11c16e080f61611bbdd9e763586c5375676a190d

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp313-cp313-win_arm64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp313-cp313-win_arm64.whl
Algorithm Hash digest
SHA256 6498a4f0df85a3e0aa5209453c3a6706fc56dfb55626328c28b3f468ccd539c9
MD5 8dc8e282d50ff328b2198ffcbc2739f7
BLAKE2b-256 6a0cd956b31041f6a59038bc303af818e713b1d3730733de4d5431f250b3b175

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 35c35574367c3689a8234599f07412fd4617039a3d5b160fb4b953bcd06af7ec
MD5 7ff982dfb4735e128c3c7ba34abbadac
BLAKE2b-256 c8773fdc23ef4218273c65e5413b22a76bb98a3721b20c464c6d38194aac190a

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 3c088b5d8ebe97166371cb0f48f7c366eb71c0bcfbaa67a5c725ea6ee4dcb45d
MD5 be4283a1adaadd2dd70d3a312527744e
BLAKE2b-256 664451ae3427dc161ae97b26640eef372c98bfc68ecaa10023519be73ce6a632

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp312-cp312-win_arm64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp312-cp312-win_arm64.whl
Algorithm Hash digest
SHA256 c09fb701d6c7c3679c1696dbde29f821a53091a2bf6082a61ea64ea2b5cacac1
MD5 28bb62ea86c3901d4f3e567a44d6ce0f
BLAKE2b-256 91c589b85170f91837b68cd5567379b37d59fc0fe0e806c15de1ca1e9b677b23

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ac0d9c19408bf9803de9ad402c53f9b4192d4a19c8d4053ca23239162998f5f5
MD5 4e688a76b089a2e6cda9431dd991ad72
BLAKE2b-256 a5a178ce6c14d235ce773a5b81ae82eb9a314ae751da55d755c35b65a68725fd

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 6f77d1cc18525e23f8e1a21e4676d32bee9f4dcbc8c6ddc4d2195380d8e9fc1a
MD5 d8fe6bc5b0d362c769d366dac639fdd5
BLAKE2b-256 bf2a2253016a16d2163750cffb23ffdfc681f4e336e2428bdd5222cd9464eee7

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp311-cp311-win_arm64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 413cf14df73095e3c1f8bd5328868e76d4e0ca17ee980df2c2dc519c671fbcbe
MD5 c1ab1cb3a7984ad13752ba6e32301acf
BLAKE2b-256 35672e1f627737ddb6b9f5cfd9fb714049f3a08beed57ce347263e6bf3c36f62

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0fe1d251c2cbf6d018cda90615c766d4ff7f4f746e77c3c2d29f6a8d38e08977
MD5 80bccbc451f699463233b76ffa9b6712
BLAKE2b-256 e7f99defbad74907bad08ad33e7fe11a20445c504fd2924572c275c32a9da39b

See more details on using hashes here.

File details

Details for the file amulet_mutf8-1.0.7-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for amulet_mutf8-1.0.7-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4ce86966d06a68e22bf2de6507dc24740fe7681967b21140ae687cc1f57ca558
MD5 150ceb397e7b49e3d18fa02959ad052d
BLAKE2b-256 115d64837608b628f0b6e0bf0e5748f266b7a17c2e55238d63ec8cf7f657e142

See more details on using hashes here.

Supported by

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