本文整理了Java中org.jruby.Ruby.getDefaultEncoding
方法的一些代码示例,展示了Ruby.getDefaultEncoding
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getDefaultEncoding
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getDefaultEncoding
[英]Return the default internal encoding, if set, or UTF-8 by default.
[中]返回默认的内部编码(如果已设置),或默认返回UTF-8。
代码示例来源:origin: org.jruby/jruby-core
/**
* Executes the block once for each child in the directory
* (i.e. all the directory entries except for "." and "..").
*/
public IRubyObject each_child(ThreadContext context, Block block) {
return each_child(context, context.runtime.getDefaultEncoding(), block);
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Executes the block once for each child in the directory
* (i.e. all the directory entries except for "." and "..").
*/
public IRubyObject each_child(ThreadContext context, Block block) {
return each_child(context, context.runtime.getDefaultEncoding(), block);
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Get the default java.nio.charset.Charset for the current default internal encoding.
*/
public Charset getDefaultCharset() {
Encoding enc = getDefaultEncoding();
Charset charset = EncodingUtils.charsetForEncoding(enc);
return charset;
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Get the default java.nio.charset.Charset for the current default internal encoding.
*/
public Charset getDefaultCharset() {
Encoding enc = getDefaultEncoding();
Charset charset = EncodingUtils.charsetForEncoding(enc);
return charset;
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Executes the block once for each entry in the directory.
*/
@JRubyMethod(name = "each")
public IRubyObject each(ThreadContext context, Block block) {
return block.isGiven() ? each(context, context.runtime.getDefaultEncoding(), block) : enumeratorize(context.runtime, this, "each");
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Executes the block once for each entry in the directory.
*/
@JRubyMethod(name = "each")
public IRubyObject each(ThreadContext context, Block block) {
return block.isGiven() ? each(context, context.runtime.getDefaultEncoding(), block) : enumeratorize(context.runtime, this, "each");
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Returns an array containing all of the filenames in the given directory.
*/
@JRubyMethod(name = "entries", meta = true)
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject arg) {
Ruby runtime = context.runtime;
RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg));
return entriesCommon(context, path.asJavaString(), runtime.getDefaultEncoding(), false);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Returns an array containing all of the filenames in the given directory.
*/
@JRubyMethod(name = "entries", meta = true)
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject arg) {
Ruby runtime = context.runtime;
RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg));
return entriesCommon(context, path.asJavaString(), runtime.getDefaultEncoding(), false);
}
代码示例来源:origin: org.jruby/jruby-complete
private static RubyArray childrenCommon(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts) {
Encoding encoding = null;
if (opts != context.nil) {
IRubyObject encodingArg = ArgsUtil.extractKeywordArg(context, "encoding", opts);
if (encodingArg != context.nil) {
encoding = context.runtime.getEncodingService().getEncodingFromObject(encodingArg);
}
}
if (encoding == null) encoding = context.runtime.getDefaultEncoding();
return entriesCommon(context, RubyFile.get_path(context, arg).asJavaString(), encoding, true);
}
代码示例来源:origin: org.jruby/jruby-core
private static RubyArray childrenCommon(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts) {
Encoding encoding = null;
if (opts != context.nil) {
IRubyObject encodingArg = ArgsUtil.extractKeywordArg(context, "encoding", opts);
if (encodingArg != context.nil) {
encoding = context.runtime.getEncodingService().getEncodingFromObject(encodingArg);
}
}
if (encoding == null) encoding = context.runtime.getDefaultEncoding();
return entriesCommon(context, RubyFile.get_path(context, arg).asJavaString(), encoding, true);
}
代码示例来源:origin: org.jruby/jruby-complete
private static IRubyObject eachChildCommon(ThreadContext context, IRubyObject recv, RubyString path, RubyEncoding encoding, Block block) {
final Ruby runtime = context.runtime;
if (block.isGiven()) {
RubyDir dir = (RubyDir) runtime.getDir().newInstance(context, path, Block.NULL_BLOCK);
dir.each_child(context, encoding == null ? runtime.getDefaultEncoding() : encoding.getEncoding(), block);
return context.nil;
}
if (encoding == null) {
return enumeratorize(runtime, recv, "each_child", path);
}
return enumeratorize(runtime, recv, "each_child", path, encoding);
}
代码示例来源:origin: org.jruby/jruby-complete
private static IRubyObject foreachCommon(ThreadContext context, IRubyObject recv, RubyString path, RubyEncoding encoding, Block block) {
final Ruby runtime = context.runtime;
if (block.isGiven()) {
RubyDir dir = (RubyDir) runtime.getDir().newInstance(context, path, Block.NULL_BLOCK);
dir.each(context, encoding == null ? runtime.getDefaultEncoding() : encoding.getEncoding(), block);
return context.nil;
}
if (encoding == null) {
return enumeratorize(runtime, recv, "foreach", path);
}
return enumeratorize(runtime, recv, "foreach", path, encoding);
}
代码示例来源:origin: org.jruby/jruby-core
private static IRubyObject eachChildCommon(ThreadContext context, IRubyObject recv, RubyString path, RubyEncoding encoding, Block block) {
final Ruby runtime = context.runtime;
if (block.isGiven()) {
RubyDir dir = (RubyDir) runtime.getDir().newInstance(context, path, Block.NULL_BLOCK);
dir.each_child(context, encoding == null ? runtime.getDefaultEncoding() : encoding.getEncoding(), block);
return context.nil;
}
if (encoding == null) {
return enumeratorize(runtime, recv, "each_child", path);
}
return enumeratorize(runtime, recv, "each_child", path, encoding);
}
代码示例来源:origin: org.jruby/jruby-core
private static IRubyObject foreachCommon(ThreadContext context, IRubyObject recv, RubyString path, RubyEncoding encoding, Block block) {
final Ruby runtime = context.runtime;
if (block.isGiven()) {
RubyDir dir = (RubyDir) runtime.getDir().newInstance(context, path, Block.NULL_BLOCK);
dir.each(context, encoding == null ? runtime.getDefaultEncoding() : encoding.getEncoding(), block);
return context.nil;
}
if (encoding == null) {
return enumeratorize(runtime, recv, "foreach", path);
}
return enumeratorize(runtime, recv, "foreach", path, encoding);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "entries", meta = true)
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts) {
Ruby runtime = context.runtime;
Encoding encoding = null;
RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg));
if (opts != context.nil) {
IRubyObject encodingArg = ArgsUtil.extractKeywordArg(context, "encoding", opts);
if (encodingArg != context.nil) {
encoding = runtime.getEncodingService().getEncodingFromObject(encodingArg);
}
}
if (encoding == null) encoding = runtime.getDefaultEncoding();
return entriesCommon(context, path.asJavaString(), encoding, false);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "entries", meta = true)
public static RubyArray entries(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject opts) {
Ruby runtime = context.runtime;
Encoding encoding = null;
RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg));
if (opts != context.nil) {
IRubyObject encodingArg = ArgsUtil.extractKeywordArg(context, "encoding", opts);
if (encodingArg != context.nil) {
encoding = runtime.getEncodingService().getEncodingFromObject(encodingArg);
}
}
if (encoding == null) encoding = runtime.getDefaultEncoding();
return entriesCommon(context, path.asJavaString(), encoding, false);
}
内容来源于网络,如有侵权,请联系作者删除!