Skip to main content

bytes_to_text

Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (\ufffd).

Return any non-bytes objects without change.
def bytes_to_text(
s: any,
encoding: string
) - > string|any

Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (\ufffd). Return any non-bytes objects without change.

Parameters

NameTypeDescription
sanyThe input object to be converted if it is a bytes instance
encodingstringThe character encoding used to decode the bytes object, such as "utf-8"

Returns

TypeDescription
`stringany`