/** * RubySymbol is created by passing in a String and bytes are extracted from that. We will * pass in encoding of that string after construction but before use so it does not forget * what it is. */ public void associateEncoding(Encoding encoding) { symbolBytes.setEncoding(encoding); }
protected RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, Encoding enc, int cr) { this(runtime, rubyClass, value); flags |= cr; value.setEncoding(enc); }
@Override public void setEncoding(Encoding encoding) { completeSource.setEncoding(encoding); encodeExistingScriptLines(encoding); }
public void setEncoding(Encoding encoding) { setCurrentEncoding(encoding); src.setEncoding(encoding); lexb.setEncoding(encoding); }
protected ByteList createByteList(RubyLexer lexer) { ByteList bytelist = new ByteList(15); bytelist.setEncoding(lexer.getEncoding()); return bytelist; }
protected void flush_string_content(Encoding encoding) { if (delayed != null) { int len = lex_p - tokp; if (len > 0) { delayed.setEncoding(encoding); delayed.append(lexb.makeShared(tokp, len)); } dispatchDelayedToken(RipperParser.tSTRING_CONTENT); tokp = lex_p; } }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { ByteList aChar = ByteList.create(""); aChar.setEncoding(lexer.getEncoding()); yyVal = lexer.createStr(aChar, 0); return yyVal; } };
@Override public void setEncoding(Encoding encoding) { if (encoding != value.getEncoding()) { if (shareLevel == SHARE_LEVEL_BYTELIST) modify(); else modifyCheck(); value.setEncoding(encoding); } }
protected void flush_string_content(Encoding encoding) { if (delayed != null) { int len = lex_p - tokp; if (len > 0) { delayed.setEncoding(encoding); delayed.append(lexb.makeShared(tokp, len)); } dispatchDelayedToken(RipperParser.tSTRING_CONTENT); tokp = lex_p; } }
@Override public void setEncoding(Encoding encoding) { if (encoding != value.getEncoding()) { if (shareLevel == SHARE_LEVEL_BYTELIST) modify(); else modifyCheck(); value.setEncoding(encoding); } }
@JRubyMethod(name = "*", required = 1, compat = RUBY1_9) public IRubyObject op_mul19(ThreadContext context, IRubyObject other) { RubyString result = multiplyByteList(context, other); result.value.setEncoding(value.getEncoding()); result.copyCodeRange(this); return result; }
public static void associateEncoding(CodeRangeable string, Encoding enc) { final ByteList value = string.getByteList(); if (value.getEncoding() != enc) { if (!CodeRangeSupport.isCodeRangeAsciiOnly(string) || !enc.isAsciiCompatible()) string.clearCodeRange(); value.setEncoding(enc); } }
@JRubyMethod(name = "*", required = 1) public IRubyObject op_mul19(ThreadContext context, IRubyObject other) { RubyString result = multiplyByteList(context, other); result.value.setEncoding(value.getEncoding()); result.copyCodeRangeForSubstr(this, value.getEncoding()); return result; }
@JRubyMethod(name = "*", required = 1) public IRubyObject op_mul19(ThreadContext context, IRubyObject other) { RubyString result = multiplyByteList(context, other); result.value.setEncoding(value.getEncoding()); result.copyCodeRangeForSubstr(this, value.getEncoding()); return result; }
private RubyString makeString(Ruby runtime, ByteList buffer, boolean isCached) { ByteList newBuf = isCached ? new ByteList(buffer) : buffer; if (runtime.is1_9()) newBuf.setEncoding(getReadEncoding()); RubyString str = RubyString.newString(runtime, newBuf); str.setTaint(true); return str; }
/** rb_reg_source * */ @JRubyMethod public IRubyObject source() { check(); Encoding enc = (pattern == null) ? str.getEncoding() : pattern.getEncoding(); ByteList newStr = str.dup(); newStr.setEncoding(enc); return RubyString.newString(getRuntime(), newStr).infectBy(this); }
private static ByteList regexpDescription19(Ruby runtime, byte[] s, int start, int len, RegexpOptions options, Encoding enc) { ByteList description = new ByteList(); description.setEncoding(enc); description.append((byte)'/'); Encoding resultEnc = runtime.getDefaultInternalEncoding(); if (resultEnc == null) resultEnc = runtime.getDefaultExternalEncoding(); appendRegexpString19(runtime, description, s, start, len, enc, resultEnc); description.append((byte)'/'); appendOptions(description, options); if (options.isEncodingNone()) description.append((byte) 'n'); return description; }
@Override public ByteList gets() { IRubyObject result = io.callMethod(io.getRuntime().getCurrentContext(), "gets"); if (result.isNil()) return null; ByteList bytelist = result.convertToString().getByteList(); offset += bytelist.getRealSize(); bytelist.setEncoding(encoding); if (scriptLines != null) scriptLines.append(RubyString.newString(scriptLines.getRuntime(), bytelist)); return bytelist; }
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); }