本文整理汇总了C++中Encoding::get_encoding方法的典型用法代码示例。如果您正苦于以下问题:C++ Encoding::get_encoding方法的具体用法?C++ Encoding::get_encoding怎么用?C++ Encoding::get_encoding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::get_encoding方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_enc_from_index
rb_encoding* rb_enc_from_index(int index) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc = Encoding::from_index(env->state(), index);
if(enc->nil_p()) return 0;
return enc->get_encoding();
}
示例2: rb_enc_find
rb_encoding* rb_enc_find(const char* name) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc = Encoding::find(env->state(), name);
if(enc->nil_p()) return 0;
return enc->get_encoding();
}
示例3:
rb_encoding *rb_default_internal_encoding(void) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc = Encoding::find(env->state(), "internal");
if(enc->nil_p()) {
return 0;
} else {
return enc->get_encoding();
}
}
示例4: rb_filesystem_encoding
rb_encoding* rb_filesystem_encoding(void) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc = Encoding::find(env->state(), "filesystem");
if(enc->nil_p()) {
return rb_ascii8bit_encoding();
} else {
return enc->get_encoding();
}
}
示例5: rb_locale_encoding
rb_encoding* rb_locale_encoding(void) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc = Encoding::find(env->state(), "locale");
if(enc->nil_p()) {
return rb_usascii_encoding();
} else {
return enc->get_encoding();
}
}
示例6: rb_enc_get_index
int rb_enc_get_index(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* val = env->get_object(obj);
Encoding* enc = Encoding::get_object_encoding(env->state(), val);
if(enc->nil_p()) return 0;
return Encoding::find_index(env->state(), enc->get_encoding()->name);
}
示例7: rb_enc_get
rb_encoding* rb_enc_get(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* val = env->get_object(obj);
if(!val->reference_p() && !val->symbol_p()) return 0;
Encoding* enc = Encoding::get_object_encoding(env->state(), val);
if(enc->nil_p()) return 0;
return enc->get_encoding();
}
示例8: rb_enc_get
rb_encoding* rb_enc_get(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
int index = rb_enc_get_index(obj);
if(index < 0) return 0;
Encoding* enc = as<Encoding>(
Encoding::encoding_list(env->state())->get(env->state(), index));
return enc->get_encoding();
}
示例9: rb_to_encoding
rb_encoding* rb_to_encoding(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
int index = rb_to_encoding_index(obj);
if(index < 0) return 0;
Encoding* enc = try_as<Encoding>(Encoding::from_index(env->state(), index));
if(!enc) return 0;
return enc->get_encoding();
}
示例10: rb_external_str_new_with_enc
VALUE rb_external_str_new_with_enc(const char* string, long size, rb_encoding* encoding) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
String* str = String::create(env->state(), string, size);
str->taint(env->state());
Encoding* enc = Encoding::find(env->state(), encoding->name);
if(enc == Encoding::usascii_encoding(env->state())
&& !CBOOL(str->ascii_only_p(env->state()))) {
str->encoding(env->state(), Encoding::ascii8bit_encoding(env->state()));
} else {
str->encoding(env->state(), enc);
}
return rb_str_conv_enc(env->get_handle(str), enc->get_encoding(),
rb_default_internal_encoding());
}
示例11: rb_enc_get_index
int rb_enc_get_index(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* val = env->get_object(obj);
Encoding* enc;
if(String* str = try_as<String>(val)) {
enc = str->encoding(env->state());
} else if(Regexp* reg = try_as<Regexp>(val)) {
enc = reg->encoding(env->state());
} else if(Symbol* sym = try_as<Symbol>(val)) {
enc = sym->encoding(env->state());
} else {
rb_raise(rb_eArgError, "object does not have an associated Encoding");
}
if(enc->nil_p()) return -1;
return Encoding::find_index(env->state(), enc->get_encoding()->name);
}
示例12: rb_to_encoding_index
int rb_to_encoding_index(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc = nil<Encoding>();
switch(TYPE(obj)) {
case T_ENCODING:
enc = c_as<Encoding>(env->get_object(obj));
break;
case T_STRING:
enc = Encoding::find(env->state(), RSTRING_PTR(obj));
break;
default:
obj = rb_funcall(obj, rb_intern("to_str"), 0);
enc = Encoding::find(env->state(), RSTRING_PTR(obj));
}
if(enc->nil_p()) return -1;
return Encoding::find_index(env->state(), enc->get_encoding()->name);
}