private IRubyObject multiByteLStrip(ThreadContext context, Encoding enc, byte[]bytes, int s, int end) { final Ruby runtime = context.runtime; int p = s; while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!ASCII.isSpace(c)) break; p += codeLength(enc, c); } if (p > s) { view(p - s, end - p); return this; } return context.nil; }
private IRubyObject multiByteLStrip(ThreadContext context, Encoding enc, byte[]bytes, int s, int end) { final Ruby runtime = context.runtime; int p = s; while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!ASCII.isSpace(c)) break; p += codeLength(enc, c); } if (p > s) { view(p - s, end - p); return this; } return context.nil; }
private IRubyObject multiByteLStrip(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { int p = s; while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!ASCII.isSpace(c)) break; p += codeLength(runtime, enc, c); } if (p > s) { view(p - s, end - p); return this; } return runtime.getNil(); }
private IRubyObject multiByteLStrip(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { int p = s; while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!ASCII.isSpace(c)) break; p += codeLength(runtime, enc, c); } if (p > s) { view(p - s, end - p); return this; } return runtime.getNil(); }
private boolean isPrintable() { Ruby runtime = getRuntime(); int p = symbolBytes.getBegin(); int end = p + symbolBytes.getRealSize(); byte[]bytes = symbolBytes.getUnsafeBytes(); Encoding enc = symbolBytes.getEncoding(); while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!enc.isPrint(c)) return false; p += codeLength(runtime, enc, c); } return true; }
private boolean isPrintable() { Ruby runtime = getRuntime(); int p = symbolBytes.getBegin(); int end = p + symbolBytes.getRealSize(); byte[] bytes = symbolBytes.getUnsafeBytes(); Encoding enc = symbolBytes.getEncoding(); while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!enc.isPrint(c)) return false; p += codeLength(enc, c); } return true; }
private boolean isPrintable() { Ruby runtime = getRuntime(); int p = symbolBytes.getBegin(); int end = p + symbolBytes.getRealSize(); byte[]bytes = symbolBytes.getUnsafeBytes(); Encoding enc = symbolBytes.getEncoding(); while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!enc.isPrint(c)) return false; p += codeLength(runtime, enc, c); } return true; }
private boolean isPrintable() { Ruby runtime = getRuntime(); int p = symbolBytes.getBegin(); int end = p + symbolBytes.getRealSize(); byte[] bytes = symbolBytes.getUnsafeBytes(); Encoding enc = symbolBytes.getEncoding(); while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); if (!enc.isPrint(c)) return false; p += codeLength(enc, c); } return true; }
private IRubyObject each_codepointCommon(ThreadContext context, Block block) { Ruby runtime = context.runtime; byte bytes[] = value.getUnsafeBytes(); int p = value.getBegin(); int end = p + value.getRealSize(); Encoding enc = value.getEncoding(); while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); int n = codeLength(runtime, enc, c); block.yield(context, runtime.newFixnum(c)); p += n; } return this; }
private IRubyObject each_codepointCommon(ThreadContext context, Block block) { Ruby runtime = context.runtime; byte bytes[] = value.getUnsafeBytes(); int p = value.getBegin(); int end = p + value.getRealSize(); Encoding enc = value.getEncoding(); while (p < end) { int c = codePoint(runtime, enc, bytes, p, end); int n = codeLength(runtime, enc, c); block.yield(context, runtime.newFixnum(c)); p += n; } return this; }
public final RubyString cat(int code, Encoding enc) { int n = codeLength(enc, code); modify(value.getRealSize() + n); enc.codeToMbc(code, value.getUnsafeBytes(), value.getBegin() + value.getRealSize()); value.setRealSize(value.getRealSize() + n); return this; }
public final RubyString cat(int code, Encoding enc) { int n = codeLength(enc, code); modify(value.getRealSize() + n); enc.codeToMbc(code, value.getUnsafeBytes(), value.getBegin() + value.getRealSize()); value.setRealSize(value.getRealSize() + n); return this; }
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(); }
public final RubyString cat(int code, Encoding enc) { int n = codeLength(getRuntime(), enc, code); modify(value.getRealSize() + n); enc.codeToMbc(code, value.getUnsafeBytes(), value.getBegin() + value.getRealSize()); value.setRealSize(value.getRealSize() + n); return this; }
public final RubyString cat(int code, Encoding enc) { int n = codeLength(getRuntime(), enc, code); modify(value.getRealSize() + n); enc.codeToMbc(code, value.getUnsafeBytes(), value.getBegin() + value.getRealSize()); value.setRealSize(value.getRealSize() + n); return this; }
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(); }
public final RubyString catAscii(byte[] bytes, int ptr, int ptrLen) { Encoding enc = value.getEncoding(); if (enc.isAsciiCompatible()) { EncodingUtils.encCrStrBufCat(getRuntime(), this, new ByteList(bytes, ptr, ptrLen), enc, CR_7BIT); } else { byte buf[] = new byte[enc.maxLength()]; int end = ptr + ptrLen; while (ptr < end) { int c = bytes[ptr]; int len = codeLength(enc, c); EncodingUtils.encMbcput(c, buf, 0, enc); EncodingUtils.encCrStrBufCat(getRuntime(), this, buf, 0, len, enc, CR_VALID); ptr++; } } return this; }
public final RubyString catAscii(byte[] bytes, int ptr, int ptrLen) { Encoding enc = value.getEncoding(); if (enc.isAsciiCompatible()) { EncodingUtils.encCrStrBufCat(getRuntime(), this, new ByteList(bytes, ptr, ptrLen), enc, CR_7BIT); } else { byte buf[] = new byte[enc.maxLength()]; int end = ptr + ptrLen; while (ptr < end) { int c = bytes[ptr]; int len = codeLength(enc, c); EncodingUtils.encMbcput(c, buf, 0, enc); EncodingUtils.encCrStrBufCat(getRuntime(), this, buf, 0, len, enc, CR_VALID); ptr++; } } return this; }
public final RubyString catAscii(byte[]bytes, int p, int len) { Encoding enc = value.getEncoding(); if (enc.isAsciiCompatible()) { EncodingUtils.encCrStrBufCat(getRuntime(), this, new ByteList(bytes, p, len), enc, CR_7BIT, null); } else { byte buf[] = new byte[enc.maxLength()]; int end = p + len; while (p < end) { int c = bytes[p]; int cl = codeLength(getRuntime(), enc, c); enc.codeToMbc(c, buf, 0); EncodingUtils.encCrStrBufCat(getRuntime(), this, new ByteList(bytes, p, len), enc, CR_7BIT, null); p++; } } return this; }
@JRubyMethod(name = "each_codepoint", compat = RUBY1_9) public IRubyObject each_codepoint(ThreadContext context, Block block) { Ruby runtime = context.runtime; if (!block.isGiven()) return enumeratorize(runtime, this, "each_codepoint"); checkReadable(); Encoding enc = ptr.string.getEncoding(); byte[] unsafeBytes = ptr.string.getByteList().getUnsafeBytes(); int begin = ptr.string.getByteList().getBegin(); for (;;) { if (ptr.pos >= ptr.string.size()) { return this; } int c = StringSupport.codePoint(runtime, enc, unsafeBytes, begin + ptr.pos, unsafeBytes.length); int n = StringSupport.codeLength(runtime, enc, c); block.yield(context, runtime.newFixnum(c)); ptr.pos += n; } }