Loading

Considerations for Using the String Class substring Method with Surrogate Pairs

Julkaisupäivä: Mar 24, 2026
Kuvaus

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.

Ratkaisu

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

Knowledge-artikkelin numero

000395737

 
Ladataan
Salesforce Help | Article