public StrNode(ISourcePosition position, ByteList value) { this(position, value, StringSupport.codeRangeScan(value.getEncoding(), value)); }
public StrNode(ISourcePosition position, ByteList value) { this(position, value, StringSupport.codeRangeScan(value.getEncoding(), value)); }
private boolean is7BitASCII(ByteList value) { return StringSupport.codeRangeScan(value.getEncoding(), value) == StringSupport.CR_7BIT; }
private boolean is7BitASCII(ByteList value) { return StringSupport.codeRangeScan(value.getEncoding(), value) == StringSupport.CR_7BIT; }
public final int scanForCodeRange() { int cr = getCodeRange(); if (cr == CR_UNKNOWN) { cr = codeRangeScan(value.getEncoding(), value); setCodeRange(cr); } return cr; }
public final int scanForCodeRange() { int cr = getCodeRange(); if (cr == CR_UNKNOWN) { cr = codeRangeScan(value.getEncoding(), value); setCodeRange(cr); } return cr; }
public static int codeRangeScan(Encoding enc, ByteList bytes) { return codeRangeScan(enc, bytes.getUnsafeBytes(), bytes.getBegin(), bytes.getRealSize()); }
private Encoding subBangVerifyEncoding(ThreadContext context, RubyString repl, int beg, int end) { byte[]bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newArgumentError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
private Encoding subBangVerifyEncoding(ThreadContext context, RubyString repl, int beg, int end) { byte[]bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newArgumentError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
private Encoding subBangVerifyEncoding(ThreadContext context, final RubyString repl, final int beg, final int end) { final ByteList value = this.value; byte[] bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newEncodingCompatibilityError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
private Encoding subBangVerifyEncoding(ThreadContext context, final RubyString repl, final int beg, final int end) { final ByteList value = this.value; byte[] bytes = value.getUnsafeBytes(); int p = value.getBegin(); int len = value.getRealSize(); Encoding strEnc = value.getEncoding(); if (codeRangeScan(strEnc, bytes, p, beg) != CR_7BIT || codeRangeScan(strEnc, bytes, p + end, len - end) != CR_7BIT) { throw context.runtime.newEncodingCompatibilityError( "incompatible character encodings " + strEnc + " and " + repl.value.getEncoding()); } return repl.value.getEncoding(); }
public static int scanForCodeRange(ByteList byteList) { Encoding enc = byteList.getEncoding(); if (enc.minLength() > 1 && enc.isDummy()) { return CR_BROKEN; } else { return codeRangeScan(EncodingUtils.getActualEncoding(enc, byteList), byteList); } }
public static int scanForCodeRange(ByteList byteList) { Encoding enc = byteList.getEncoding(); if (enc.minLength() > 1 && enc.isDummy()) { return CR_BROKEN; } else { return codeRangeScan(EncodingUtils.getActualEncoding(enc, byteList), byteList); } }
public StrNode createStrNode(ISourcePosition position, ByteList buffer, int flags) { Encoding bufferEncoding = buffer.getEncoding(); int codeRange = StringSupport.codeRangeScan(bufferEncoding, buffer); if ((flags & RubyYaccLexer.STR_FUNC_REGEXP) == 0 && bufferEncoding.isAsciiCompatible()) { // If we have characters outside 7-bit range and we are still ascii then change to ascii-8bit if (codeRange == StringSupport.CR_7BIT) { // Do nothing like MRI } else if (getEncoding() == RubyYaccLexer.USASCII_ENCODING && bufferEncoding != RubyYaccLexer.UTF8_ENCODING) { codeRange = ParserSupport.associateEncoding(buffer, RubyYaccLexer.ASCII8BIT_ENCODING, codeRange); } } return new StrNode(position, buffer, codeRange); }
public IRubyObject createStr(ByteList buffer, int flags) { Encoding bufferEncoding = buffer.getEncoding(); int codeRange = StringSupport.codeRangeScan(bufferEncoding, buffer); if ((flags & STR_FUNC_REGEXP) == 0 && bufferEncoding.isAsciiCompatible()) { // If we have characters outside 7-bit range and we are still ascii then change to ascii-8bit if (codeRange == StringSupport.CR_7BIT) { // Do nothing like MRI } else if (getEncoding() == USASCII_ENCODING && bufferEncoding != UTF8_ENCODING) { codeRange = RipperParserBase.associateEncoding(buffer, ASCII8BIT_ENCODING, codeRange); } } return getRuntime().newString(buffer); }
public IRubyObject createStr(ByteList buffer, int flags) { Encoding bufferEncoding = buffer.getEncoding(); int codeRange = StringSupport.codeRangeScan(bufferEncoding, buffer); if ((flags & STR_FUNC_REGEXP) == 0 && bufferEncoding.isAsciiCompatible()) { // If we have characters outside 7-bit range and we are still ascii then change to ascii-8bit if (codeRange == StringSupport.CR_7BIT) { // Do nothing like MRI } else if (getEncoding() == USASCII_ENCODING && bufferEncoding != UTF8_ENCODING) { codeRange = RipperParserBase.associateEncoding(buffer, ASCII8BIT_ENCODING, codeRange); } } return getRuntime().newString(buffer); }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position, false); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); frozen = head.isFrozen() && tail.isFrozen(); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }
public StrNode(ISourcePosition position, StrNode head, StrNode tail) { super(position, false); ByteList headBL = head.getValue(); ByteList tailBL = tail.getValue(); ByteList myValue = new ByteList(headBL.getRealSize() + tailBL.getRealSize()); myValue.setEncoding(headBL.getEncoding()); myValue.append(headBL); myValue.append(tailBL); frozen = head.isFrozen() && tail.isFrozen(); value = myValue; codeRange = StringSupport.codeRangeScan(value.getEncoding(), value); }