Skip to main content

Convert a string to bytes type or str type

Project description

textconv

A bulletproof way of converting a string to a byte string or a text string.

APIs are designed to encode or decode raise-free. In most cases, input object will be either a text string (str type) or a byte string (bytes type), and default encoding is 'utf-8'.

Usage:

from textconv.text import to_text, to_bytes

# To text string
text_string = to_text(b'caf\xc3\xa9')

# To byte string
byte_string = to_bytes(u'caf\xe9', encoding="latin-1")

# A raise-free version of `str(obj)`
# if a non-string object is  provided
text_string = to_text(obj)

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

textconv-0.0.1.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

textconv-0.0.1-py3-none-any.whl (4.9 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