Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Character and Byte String Processing - Overview 

Character Strings and Byte Chains

Other versions: 7.31 | 7.40 | 7.54

Character Strings

Character-like data objects contain character strings. A character-like data object either has a character-like data type (c, n, or string) or it is a date/time type (d or t), or it is a flat structure with exclusively character-like components.

ABAP supports the character format UCS-2 and a character always occupies two bytes. This ensures that all characters from the system code page UTF-16 are handled correctly (except for those in the surrogate area). These characters occupy four bytes and hence are handled as two characters by ABAP. This can produce unexpected results when cutting character strings or comparing individual characters in character sets.

Byte Chains

Byte-like data objects contain byte chains (or byte strings). A byte-like data object always has the byte-like data type x or xstring.


Example

A byte string of type xstring contains a byte chain, which is decoded in accordance with codepage UTF-8 into a text in a text string of type string.

DATA hex  TYPE xstring VALUE '48656C6C6F20576F726C64'. 
DATA text TYPE string. 

text = cl_abap_conv_codepage=>create_in( )->convert( hex ). 

cl_demo_output=>display( text ).