Skip to main content

Library for simplified work with encoding

Project description

PyByle

PyByle is a small library for easy interaction with file and string encodings.

The library currently uses python 3.10 and supports 97 possible encodings The next version of python 3.11 supports all the same encodings as python 3.10 You can learn more about the list of encodings for different versions of the interpreter here: https://docs.python.org/3.10/library/codecs.html#standard-encodings

Installing

pip install pybyle

Getting a complete list of supported characters in a given encoding.

import pybyle


pybyle.get_charset('ascii')  # ['\x00', '\x01', '\x02', '\x03', '\x04', ...]

Converting a string from one encoding to another. Attention! All unsupported characters will be replaced with the set character!

import pybyle


pybyle.convert_encoding('Привет, мир! Hello, world!', encoding='ascii')  # ??????, ???! Hello, world!
pybyle.convert_encoding('Привет, мир! Hello, world!', encoding='ascii', substitute='_')  # ______, ___! Hello, world!

Specifies the encoding of the binary string.

import pybyle


pybyle.detect_bytes_encoding(b'\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82')  # utf-8

Determining the encoding for a given file.

import pybyle


pybyle.detect_file_encoding('example_utf_8_file.txt')  # utf-8
pybyle.detect_file_encoding('example_cp037_file.txt')  # cp037

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

pybyle-1.0.0.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

pybyle-1.0.0-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

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