protected final CoderResult encodeMalformedOrUnmappable(CharBuffer source, int ch, boolean flush) { /* * if the character is a lead surrogate, we need to call encodeTrail to attempt to match * it up with a trail surrogate. if not, the character is unmappable. */ return (UTF16.isSurrogate((char) ch)) ? encodeTrail(source, (char) ch, flush) : CoderResult.unmappableForLength(1); }
private final CoderResult encodeChar(CharBuffer source, ByteBuffer target, IntBuffer offsets, char ch) { int sourceIndex = source.position() - 1; CoderResult cr; int char32; if (UTF16.isSurrogate(ch)) { cr = handleSurrogates(source, ch); if (cr != null) return cr; char32 = fromUChar32; fromUChar32 = 0; } else { char32 = ch; } /* We cannot get any larger than 10FFFF because we are coming from UTF-16 */ // temp[0 ^ endianXOR] = (byte) (char32 >>> 24); // (always 0) temp[1 ^ endianXOR] = (byte) (char32 >>> 16); // same as (byte)((char32 >>> 16) & 0x1f) temp[2 ^ endianXOR] = (byte) (char32 >>> 8); temp[3 ^ endianXOR] = (byte) (char32); cr = fromUWriteBytes(this, temp, 0, 4, target, offsets, sourceIndex); return (cr.isUnderflow() ? null : cr); } }
if (!isSurrogate(single)) { return single;
if (!isSurrogate(single)) { return single;
if (isSurrogate(ch)) { if (isLeadSurrogate(ch)) { if (++offset16 < source.length() && isTrailSurrogate(source.charAt(offset16))) {
if (isSurrogate(ch)) { if (isLeadSurrogate(ch)) { if (++offset16 < source.length() && isTrailSurrogate(source.charAt(offset16))) {
/** * Set a code point into a UTF16 position. Adjusts target according if we are replacing a * non-supplementary codepoint with a supplementary and vice versa. * * @param target Stringbuffer * @param offset16 UTF16 position to insert into * @param char32 Code point * @stable ICU 2.1 */ public static void setCharAt(StringBuffer target, int offset16, int char32) { int count = 1; char single = target.charAt(offset16); if (isSurrogate(single)) { // pairs of the surrogate with offset16 at the lead char found if (isLeadSurrogate(single) && (target.length() > offset16 + 1) && isTrailSurrogate(target.charAt(offset16 + 1))) { count++; } else { // pairs of the surrogate with offset16 at the trail char // found if (isTrailSurrogate(single) && (offset16 > 0) && isLeadSurrogate(target.charAt(offset16 - 1))) { offset16--; count++; } } } target.replace(offset16, offset16 + count, valueOf(char32)); }
private final CoderResult encodeChar(CharBuffer source, ByteBuffer target, IntBuffer offsets, char ch) { int sourceIndex = source.position() - 1; CoderResult cr; if (UTF16.isSurrogate(ch)) { cr = handleSurrogates(source, ch); if (cr != null) return cr; char trail = UTF16.getTrailSurrogate(fromUChar32); fromUChar32 = 0; // 4 bytes temp[0 ^ endianXOR] = (byte) (ch >>> 8); temp[1 ^ endianXOR] = (byte) (ch); temp[2 ^ endianXOR] = (byte) (trail >>> 8); temp[3 ^ endianXOR] = (byte) (trail); cr = fromUWriteBytes(this, temp, 0, 4, target, offsets, sourceIndex); } else { // 2 bytes temp[0 ^ endianXOR] = (byte) (ch >>> 8); temp[1 ^ endianXOR] = (byte) (ch); cr = fromUWriteBytes(this, temp, 0, 2, target, offsets, sourceIndex); } return (cr.isUnderflow() ? null : cr); } }
if (isSurrogate(ch)) { if (isLeadSurrogate(ch)) { ++offset16;
char single = target[offset16]; if (isSurrogate(single)) {
if (!UTF16.isSurrogate(char16)) { toULength = 0; target.put(char16);
) { ++src; } else if(!UTF16.isSurrogate((char)c)) { break; } else {
if (UTF16.isSurrogate((char) mySourceChar)) {
} else if (!UTF16.isSurrogate((char) c)) {
) { ++src; } else if(!UTF16.isSurrogate((char)c)) { break; } else {
} else { n=((caseFlags!=null && caseFlags[j])? 1 : 0)<<31L; if(!UTF16.isSurrogate(c)) { n|=c; } else if(UTF16.isLeadSurrogate(c) && (j+1)<srcLength && UTF16.isTrailSurrogate(c2=src.charAt(j+1))) {
++src; } else { if(UTF16.isSurrogate((char)c)) { char c2; if(UTF16Plus.isSurrogateLead(c)) {
if (!isSurrogate(single)) { return single;
if (!Character.isJavaIdentifierPart(c)) { if (UTF16.isSurrogate(c)) { c= document.getChar(pos); if (!Character.isJavaIdentifierPart(c)) { if (UTF16.isSurrogate(c)) {
if (!Character.isJavaIdentifierPart(c)) { if (UTF16.isSurrogate(c)) { c= document.getChar(pos); if (!Character.isJavaIdentifierPart(c)) { if (UTF16.isSurrogate(c)) {