本文整理了Java中org.jruby.Ruby.getDefaultInternalEncoding
方法的一些代码示例,展示了Ruby.getDefaultInternalEncoding
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getDefaultInternalEncoding
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getDefaultInternalEncoding
[英]This is an internal encoding if actually specified via default_internal= or passed in via -E.
[中]如果实际通过默认值_internal=指定或通过-E传入,则这是一种内部编码。
代码示例来源:origin: org.jruby/jruby-complete
/**
* Return the default internal encoding, if set, or UTF-8 by default.
*
* @return the default encoding used for new Ruby strings
*/
public Encoding getDefaultEncoding() {
Encoding enc = getDefaultInternalEncoding();
if (enc == null) {
enc = UTF8Encoding.INSTANCE;
}
return enc;
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Return the default internal encoding, if set, or UTF-8 by default.
*
* @return the default encoding used for new Ruby strings
*/
public Encoding getDefaultEncoding() {
Encoding enc = getDefaultInternalEncoding();
if (enc == null) {
enc = UTF8Encoding.INSTANCE;
}
return enc;
}
代码示例来源:origin: org.jruby/jruby-complete
public static Encoding encGet(ThreadContext context, IRubyObject obj) {
if (obj instanceof EncodingCapable) {
return ((EncodingCapable)obj).getEncoding();
}
return context.runtime.getDefaultInternalEncoding();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static Encoding encGet(ThreadContext context, IRubyObject obj) {
if (obj instanceof EncodingCapable) {
return ((EncodingCapable)obj).getEncoding();
}
return context.runtime.getDefaultInternalEncoding();
}
代码示例来源:origin: org.jruby/jruby-complete
public IRubyObject getDefaultInternal() {
return convertEncodingToRubyEncoding(runtime.getDefaultInternalEncoding());
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyString newUnicodeString(Ruby runtime, CharSequence str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static void rbEncSetDefaultInternal(ThreadContext context, IRubyObject encoding) {
Encoding[] enc_p = {context.runtime.getDefaultInternalEncoding()};
encSetDefaultEncoding(context, enc_p, encoding, "internal");
context.runtime.setDefaultInternalEncoding(enc_p[0]);
}
代码示例来源:origin: org.jruby/jruby-core
public static void rbEncSetDefaultInternal(ThreadContext context, IRubyObject encoding) {
Encoding[] enc_p = {context.runtime.getDefaultInternalEncoding()};
encSetDefaultEncoding(context, enc_p, encoding, "internal");
context.runtime.setDefaultInternalEncoding(enc_p[0]);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static void rbEncSetDefaultInternal(ThreadContext context, IRubyObject encoding) {
Encoding[] enc_p = {context.runtime.getDefaultInternalEncoding()};
encSetDefaultEncoding(context, enc_p, encoding, "internal");
context.runtime.setDefaultInternalEncoding(enc_p[0]);
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyString newUnicodeString(Ruby runtime, String str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyString newUnicodeString(Ruby runtime, String str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyString newUnicodeString(Ruby runtime, String str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyString newUnicodeString(Ruby runtime, String str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyString newUnicodeString(Ruby runtime, CharSequence str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyString newUnicodeString(Ruby runtime, CharSequence str) {
Encoding defaultInternal = runtime.getDefaultInternalEncoding();
if (defaultInternal == UTF16BEEncoding.INSTANCE) {
return newUTF16String(runtime, str);
} else {
return newUTF8String(runtime, str);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public Encoding toEncoding(Ruby runtime) {
switch (this) {
case LOCALE: return runtime.getEncodingService().getLocaleEncoding();
case EXTERNAL: return runtime.getDefaultExternalEncoding();
case INTERNAL: return runtime.getDefaultInternalEncoding();
case FILESYSTEM: return runtime.getDefaultFilesystemEncoding();
default:
throw new AssertionError("invalid SpecialEncoding: " + this);
}
}
}
代码示例来源:origin: org.jruby/jruby-core
public Encoding toEncoding(Ruby runtime) {
switch (this) {
case LOCALE: return runtime.getEncodingService().getLocaleEncoding();
case EXTERNAL: return runtime.getDefaultExternalEncoding();
case INTERNAL: return runtime.getDefaultInternalEncoding();
case FILESYSTEM: return runtime.getDefaultFilesystemEncoding();
default:
throw new AssertionError("invalid SpecialEncoding: " + this);
}
}
}
代码示例来源:origin: org.jruby/jruby-complete
protected final String validateConstant(String name, IRubyObject errorName) {
if (IdUtil.isValidConstantName(name)) return name;
Ruby runtime = getRuntime();
Encoding resultEncoding = runtime.getDefaultInternalEncoding();
if (resultEncoding == null) resultEncoding = runtime.getDefaultExternalEncoding();
// MRI is more complicated than this and distinguishes between ID and non-ID.
RubyString nameString = errorName.asString();
// MRI does strlen to check for \0 vs Ruby string length.
if ((nameString.getEncoding() != resultEncoding && !nameString.isAsciiOnly()) ||
nameString.toString().indexOf('\0') > -1 ) {
nameString = (RubyString) nameString.inspect();
}
throw getRuntime().newNameError("wrong constant name " + nameString, name);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
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;
}
代码示例来源:origin: org.jruby/jruby-complete
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;
}
内容来源于网络,如有侵权,请联系作者删除!