Loading

Considerations for Using the String Class substring Method with Surrogate Pairs

Veröffentlichungsdatum: Mar 24, 2026
Beschreibung

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.

Lösung

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).

Nummer des Knowledge-Artikels

000395737

 
Laden
Salesforce Help | Article