Convert characters to hex in Teradata

A practical review of Teradata character-to-hex conversion: what it changes in stored text, when it is suitable, and how usable the hex result stays after copying or sharing.

Is this conversion suitable?

Converting characters to hexadecimal in Teradata is a stored-text transformation. The usual SQL path is CHAR2HEXINT, which rewrites each input character as hexadecimal digits for that character’s code units in the column or session character set. Use it when the goal is a comparable, ASCII-safe dump of how the database stores a value: encoding checks, hidden-character debugging, collation mismatches, or moving a string through a channel that should stay in 0–9 and A–F.

The main benefit is lossless inspection of stored code units. Strings that look alike on a report can still differ by character set, padding, or non-printing characters; a hex dump makes those differences visible as ordinary digits. The decisive tradeoff is that wording, word breaks, and language meaning are gone. The result is also longer than the source, commonly two hex digits per LATIN character and four hex digits per UNICODE 16-bit code unit, so length, indexes, and display width all change.

Keep the original character value when people need to read, search, edit, translate, or quote the text. Hex is a diagnostic and interchange form. Plain characters remain the right stored form for reports, labels, customer-facing copy, and any workflow in which meaning matters more than a byte-level dump.

  • Choose hex when you must compare stored code units, trace unexpected characters, or pass an ASCII-safe encoding of a string.
  • Keep source characters for reading, editing, linguistic search, and anything shown to people as language.
  • Plan for a longer VARCHAR result and for a decode step that uses the same character set if the original text must come back.

What the conversion actually changes

The conversion changes the stored characters. Each source character is replaced by hexadecimal digit characters. The mapping follows the source character set, not the visual shape of the letter and not a display layer. The database then holds a different string. That is a data rewrite, not a restyle of the same letters.

Character reversal, mirrored glyphs, Unicode letter-shape substitution, CSS presentation, and bidirectional display are separate mechanisms. They rearrange or restyle appearance. CHAR2HEXINT does none of that. It encodes code units as hex digits and stores those digits.

-- Typical pattern: hex dump of a character column
SELECT
  src_txt,
  CHAR2HEXINT(src_txt) AS src_hex
FROM my_table;

Illustrative LATIN case: the letter A is stored as the single character A. After conversion the stored value is the two characters 4 and 1, the usual hexadecimal form of that letter’s Latin/ASCII code. The output type is still a character string; only the content is hex. Confirm the exact width in your system against the source character set: LATIN input is commonly two hex digits per character, UNICODE input commonly four hex digits per 16-bit code unit, and GRAPHIC data commonly four hex digits per graphic character.

Combining marks and multi-code-point emoji are not a special visual unit in this conversion. They dump as a sequence of hex groups, one group per stored code unit. That sequence is faithful to storage and easy to misread as a single Unicode code-point list. Exact grouping, width, and byte order for supplementary characters depend on the column character set and Teradata’s UNICODE representation. No sample output for those cases is supplied here; verify against the source column’s character set before treating a dump as portable code points.

Readability and usability after copying or sharing

The hex result is ordinary characters in the 0–9 and A–F range, so copy and paste keep a plain-text string in destinations that accept Latin letters and digits. That is the practical compatibility strength. Downstream files, tickets, and spreadsheets receive digits, not a styled rendering that might fall apart.

Search, filters, and exact-match joins then look for those digits. They will not find the original words. Reading order is left-to-right hex groups. Bidirectional source text does not keep its linguistic order in the dump; the dump follows storage order of code units. Editors can change a hex digit and silently corrupt the value, because the digits no longer look like the message they encode.

Assistive technology that reads character by character will typically speak hex digits rather than the original words. No scoped test of a named screen reader or sharing destination is supplied here, so treat that as expected plain-text behavior rather than a verified result in every tool. Do not generalize one successful paste into a claim that every client, export, or reader will handle the dump the same way.

A plain-text equivalent of the original wording is required whenever a person or a downstream system must understand, edit, translate, or quote the message. Keep the source column next to the hex dump, or decode with a documented inverse that uses the same character set as the original conversion. Pasting hex into a document does not restore letters by itself.

  • Copy and paste generally preserve 0–9 and A–F as plain text.
  • Full-text search and human reading need the original characters.
  • Screen readers and similar tools are expected to announce digits; that behavior is not verified here for a named product.
  • Recovering wording needs a matching decode path and the same character set as the dump.