Loading

Considerations for Using the String Class substring Method with Surrogate Pairs

Дата публикации: Mar 24, 2026
Описание

Surrogate pair characters are interpreted as a single character by combining a "high surrogate" and a "low surrogate."
Therefore, for example, if you use the substring(0, 1) method on a String variable containing a single surrogate pair to extract only the high surrogate, it will not be interpreted as a valid surrogate pair, and the character cannot be retrieved correctly.

Решение

When handling surrogate pair characters using methods such as substring, the implementation must retrieve two values (the high and low surrogates) for a single character. 
In the example above, this should be implemented as substring(0, 2).

Номер статьи базы знаний

000395737

 
Загрузка
Salesforce Help | Article