private IRubyObject multiByteSwapcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; while (s < end) { int c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } else if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }
private IRubyObject multiByteSwapcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; while (s < end) { int c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } else if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }
private IRubyObject multiByteUpcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; int c; while (s < end) { if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) { if (ASCII.isLower(c)) { bytes[s] = AsciiTables.ToUpperCaseTable[c]; modify = true; } s++; } else { c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } } return modify ? this : runtime.getNil(); }
private IRubyObject multiByteUpcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; int c; while (s < end) { if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) { if (ASCII.isLower(c)) { bytes[s] = AsciiTables.ToUpperCaseTable[c]; modify = true; } s++; } else { c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } } return modify ? this : runtime.getNil(); }
@JRubyMethod(name = "capitalize!", compat = RUBY1_9) public IRubyObject capitalize_bang19(ThreadContext context) { Ruby runtime = context.runtime; Encoding enc = checkDummyEncoding(); if (value.getRealSize() == 0) { modifyCheck(); return runtime.getNil(); } modifyAndKeepCodeRange(); int s = value.getBegin(); int end = s + value.getRealSize(); byte[]bytes = value.getUnsafeBytes(); boolean modify = false; int c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); while (s < end) { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }
@JRubyMethod(name = "capitalize!", compat = RUBY1_9) public IRubyObject capitalize_bang19(ThreadContext context) { Ruby runtime = context.runtime; Encoding enc = checkDummyEncoding(); if (value.getRealSize() == 0) { modifyCheck(); return runtime.getNil(); } modifyAndKeepCodeRange(); int s = value.getBegin(); int end = s + value.getRealSize(); byte[]bytes = value.getUnsafeBytes(); boolean modify = false; int c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); while (s < end) { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }