TEXT data type, using the database’s encoding.
Syntax
Parameters
Return Type
CONVERT_FROM returns a value of type TEXT.
Errors
If<src_encoding> is invalid, an error is thrown.
If <bytes> are malformed according to <src_encoding>, the behavior is undefined and may result in replacement characters or errors, depending on the encoding. For example, in UTF-8 encoding, malformed bytes are replaced with the � character.
Examples
Example The following code example usesCONVERT_FROM to convert the binary input \x1212003100 of type BYTEA into a TEXT string using the UTF-16 encoding. All results are displayed in UTF-8 encoding:
Rows: 1Execution time: 4.96ms
ሒ1� consists of:
ሒ, theUTF-16representation of1212.1, theUTF-16representation of0031.- The replacement character
�. Because00is a single byte, it does not form a validUTF-16sequence.
CONVERT_FROM to convert the binary input \x31a031ffffffff of type BYTEA into a TEXT string using the windows-1252 encoding:
Rows: 1Execution time: 5.07ms
1 1ÿÿÿÿ, consists of:
1, the windows-1252 representation of31., the windows-1252 representation of the non-breaking space character a0.ÿ, the windows-1252 representation offf.
BYTEA column that represents text data in a custom encoding that is specified during data loading:
BYTEA column col_bytea into TEXT using the specified encoding UTF-16, and inserts it into text_encoded_data target table:
UTF-16 input encoding with another encoding supported by the ICU library.