ABAP Keyword Documentation → ABAP Programming Guidelines → Robust ABAP → Internationalization
Splitting Texts
Other versions: 7.31 | 7.40 | 7.54
Background
Usually the characters in a character string are displayed in a code page using a fixed number of bytes. This means that it is always known in the memory where a character begins and ends. However, in some code pages, a character can be formed from a combination of several separately saved characters.
- This is done using the combined characters of some non-Unicode codepages in non-Unicode systems, where a string of characters produces a grapheme (the smallest unit of a writing system in a specific language).
- This also applies to the characters of the surrogate area of the Unicode character set, that are collectively represented in the Unicode character display UTF-16 by two consecutive 16-bit replacement codes (Surrogate). The surrogate area, for example, includes several Chinese characters that are predominantly used in Hong Kong.
Rule
Only cut texts between characters
Make sure that statements do not cut character strings in any places with composite characters or surrogates.
Details
Operations that cut character strings include:
- Subfield accesses with offsets/lengths or
substring
functions
- The
SPLIT
statement
- Every assignment to a character-like field that is too short, where one side of the original value is cut off
If texts containing combined characters or surrogates are cut, this can result in undefined characters that cannot be displayed. If there is a risk of this occurring, you can define a suitable separation position by using the method SPLIT_STRING_AT_POSITION of classCL_SCP_LINEBREAK_UTIL.