Skip to main content

16384 encode and decode

Project description

✨ pybase16384 ✨

The python binding for base16384

一种神奇的编码

pypi python implementation wheel license action

使用

  • 编码/解码文本
>>> import pybase16384 as pybs
>>> pybs.encode_to_string(b'hello!!')
栙擆羼漡
>>> pybs.decode_from_string("栙擆羼漡")
b'hello!!'
  • 编码文件
from io import BytesIO

import pybase16384 as pybs

with open("input.pcm", "rb") as f:
    data = f.read()
for i in range(1):
    pybs.encode(BytesIO(data), open("output2.pcm", 'wb'), True)
  • 解码文件
from io import BytesIO

import pybase16384 as pybs

with open("output2.pcm", "rb") as f:
    data = f.read()
for i in range(1):
    pybs.decode(BytesIO(data), open("input2.pcm", 'wb'))

公开函数

def decode(input: BinaryIO, output: BinaryIO, buf_rate: int = 10) -> None: ...

def encode(input: BinaryIO, output: BinaryIO, boolwrite_head: bool = False, buf_rate: int = 10) -> None: ...

def encode_from_string(data: str, write_head: bool = False) -> bytes: ...

def encode_to_string(data: bytes) -> str: ...

def decode_from_bytes(data: bytes) -> str: ...

def decode_from_string(data: str) -> bytes: ...
  • write_head将显式指明编码出的文本格式(utf16be),以便文本编辑器(如记事本)能够正确渲染,一般在写入文件时使用。

  • buf_rate指定读取文件的策略。当它为n时,则表示一次读取7n或者8n个字节。如果读到的字节长度小于预期,则说明长度不够, 此时,n将减半,恢复文件指针,重新读取。如果当n=1时长度仍然不够,就地encode/decode处理之。

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

pybase16384-0.1.0rc2.tar.gz (56.2 kB view hashes)

Uploaded Source

Built Distributions

pybase16384-0.1.0rc2-cp310-cp310-win_amd64.whl (72.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pybase16384-0.1.0rc2-cp310-cp310-macosx_10_15_x86_64.whl (70.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

pybase16384-0.1.0rc2-cp39-cp39-win_amd64.whl (71.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pybase16384-0.1.0rc2-cp39-cp39-macosx_10_15_x86_64.whl (70.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

pybase16384-0.1.0rc2-cp38-cp38-win_amd64.whl (71.9 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pybase16384-0.1.0rc2-cp38-cp38-macosx_10_14_x86_64.whl (70.5 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pybase16384-0.1.0rc2-cp37-cp37m-win_amd64.whl (71.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pybase16384-0.1.0rc2-cp37-cp37m-manylinux2014_x86_64.whl (80.8 kB view hashes)

Uploaded CPython 3.7m

pybase16384-0.1.0rc2-cp37-cp37m-macosx_10_14_x86_64.whl (70.3 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

pybase16384-0.1.0rc2-cp36-cp36m-win_amd64.whl (71.7 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

pybase16384-0.1.0rc2-cp36-cp36m-manylinux2014_x86_64.whl (81.0 kB view hashes)

Uploaded CPython 3.6m

pybase16384-0.1.0rc2-cp36-cp36m-macosx_10_14_x86_64.whl (70.3 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

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