}
public final int cat(byte[]bytes, int p, int len, Encoding enc, int cr) {
modify(value.getRealSize() + len);
int toCr = getCodeRange();
Encoding toEnc = value.getEncoding();
int cr2 = cr;
if (toEnc == enc) {
if (toCr == CR_UNKNOWN || (toEnc == ASCIIEncoding.INSTANCE && toCr != CR_7BIT)) {
cr = CR_UNKNOWN;
} else if (cr == CR_UNKNOWN) {
cr = codeRangeScan(enc, bytes, p, len);
}
} else {
if (!toEnc.isAsciiCompatible() || !enc.isAsciiCompatible()) {
if (len == 0) return toCr;
if (value.getRealSize() == 0) {
System.arraycopy(bytes, p, value.getUnsafeBytes(), value.getBegin() + value.getRealSize(), len);
value.setRealSize(value.getRealSize() + len);
setEncodingAndCodeRange(enc, cr);
return cr;
}
throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " + toEnc + " and " + enc);
}
if (cr == CR_UNKNOWN) cr = codeRangeScan(enc, bytes, p, len);
if (toCr == CR_UNKNOWN) {
if (toEnc == ASCIIEncoding.INSTANCE || cr != CR_7BIT) toCr = scanForCodeRange();
}
}
if (cr2 != 0) cr2 = cr;
if (toEnc != enc && toCr != CR_7BIT && cr != CR_7BIT) {
throw getRuntime().newEncodingCompatibilityError("incompatible character encodings: " + toEnc + " and " + enc);
}
final int resCr;
final Encoding resEnc;
if (toCr == CR_UNKNOWN) {
resEnc = toEnc;
resCr = CR_UNKNOWN;
} else if (toCr == CR_7BIT) {
if (cr == CR_7BIT) {