The argument is appended to the contents of this sequence. StringBuilder.appendCodePoint(int codePoint)Īppends the string representation of the codePoint argument to this sequence.
#Codepoints in java code
Unpaired surrogates within the text range count as one code point each. Thus the length (in chars) of the text range is endIndex-beginIndex. The text range begins at the specified beginIndex and extends to the char at index endIndex – 1. Returns the number of Unicode code points in the specified text range of this String. dePointCount(int beginIndex, int endIndex) If the char value at index – 1 is an unpaired low-surrogate or a high-surrogate, the surrogate value is returned. If the char value at (index – 1) is in the low-surrogate range, (index – 2) is not negative, and the char value at (index – 2) is in the high-surrogate range, then the supplementary code point value of the surrogate pair is returned. The index refers to char values (Unicode code units) and ranges from 1 to length. Returns the character (Unicode code point) before the specified index. Otherwise, the char value at the given index is returned. If the char value specified at the given index is in the high-surrogate range, the following index is less than the length of this String, and the char value at the following index is in the low-surrogate range, then the supplementary code point corresponding to this surrogate pair is returned. The index refers to char values (Unicode code units) and ranges from 0 to length() – 1. Returns the character (Unicode code point) at the specified index. The contents of the subarray are converted to chars subsequent modification of the int array does not affect the newly created string. The offset argument is the index of the first code point of the subarray and the count argument specifies the length of the subarray. String(int codePoints, int offset, int count)Īllocates a new String that contains characters from a subarray of the Unicode code point array argument. Index values refer to char code units, so a supplementary character uses two positions in the String, StringBuffer, and StringBuilder. The following table lists some of the commonly used constructor and methods.
String, StringBuffer, and StringBuilder represents a string in the UTF-16 format in which supplementary characters are represented by surrogate pairs. The String, StringBuffer, and StringBuilder classes also have contructors and methods that work with supplementary characters.