本文整理了Java中org.jruby.Ruby.newEncodingError
方法的一些代码示例,展示了Ruby.newEncodingError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newEncodingError
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newEncodingError
暂无
代码示例来源:origin: org.jruby/jruby-complete
public static int encMbcput(ThreadContext context, int c, byte[] buf, int p, Encoding enc) {
int len = enc.codeToMbc(c, buf, p);
// in MRI, this check occurs within some of the individual encoding functions, such as the
// US-ASCII check for values >= 0x80. In MRI, unlike in JRuby, we can't throw Ruby errors
// from within encoding logic, so we try to reproduce the expected results via normal
// error codes here.
// See MRI's rb_enc_mbcput and related downstream encoding functions.
if (len < 0) {
switch (len) {
case ErrorCodes.ERR_INVALID_CODE_POINT_VALUE:
throw context.runtime.newRangeError("invalid codepoint " + Long.toHexString(c & 0xFFFFFFFFL) + " in " + enc);
case ErrorCodes.ERR_TOO_BIG_WIDE_CHAR_VALUE:
throw context.runtime.newRangeError("" + (c & 0xFFFFFFFFL) + " out of char range");
}
throw context.runtime.newEncodingError(EncodingError.fromCode(len).getMessage());
}
return len;
}
代码示例来源:origin: org.jruby/jruby-core
public static int encMbcput(ThreadContext context, int c, byte[] buf, int p, Encoding enc) {
int len = enc.codeToMbc(c, buf, p);
// in MRI, this check occurs within some of the individual encoding functions, such as the
// US-ASCII check for values >= 0x80. In MRI, unlike in JRuby, we can't throw Ruby errors
// from within encoding logic, so we try to reproduce the expected results via normal
// error codes here.
// See MRI's rb_enc_mbcput and related downstream encoding functions.
if (len < 0) {
switch (len) {
case ErrorCodes.ERR_INVALID_CODE_POINT_VALUE:
throw context.runtime.newRangeError("invalid codepoint " + Long.toHexString(c & 0xFFFFFFFFL) + " in " + enc);
case ErrorCodes.ERR_TOO_BIG_WIDE_CHAR_VALUE:
throw context.runtime.newRangeError("" + (c & 0xFFFFFFFFL) + " out of char range");
}
throw context.runtime.newEncodingError(EncodingError.fromCode(len).getMessage());
}
return len;
}
代码示例来源:origin: org.jruby/jruby-complete
/** rb_str_intern
*
*/
@JRubyMethod(name = {"to_sym", "intern"})
public RubySymbol intern() {
final Ruby runtime = getRuntime();
if (scanForCodeRange() == CR_BROKEN) {
throw runtime.newEncodingError("invalid symbol in encoding " + getEncoding() + " :" + inspect());
}
RubySymbol symbol = runtime.getSymbolTable().getSymbol(value);
if (symbol.getBytes() == value) shareLevel = SHARE_LEVEL_BYTELIST;
return symbol;
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_str_intern
*
*/
@JRubyMethod(name = {"to_sym", "intern"})
public RubySymbol intern() {
final Ruby runtime = getRuntime();
if (scanForCodeRange() == CR_BROKEN) {
throw runtime.newEncodingError("invalid symbol in encoding " + getEncoding() + " :" + inspect());
}
RubySymbol symbol = runtime.getSymbolTable().getSymbol(value);
if (symbol.getBytes() == value) shareLevel = SHARE_LEVEL_BYTELIST;
return symbol;
}
内容来源于网络,如有侵权,请联系作者删除!