本文整理汇总了C++中Encoding::nil_p方法的典型用法代码示例。如果您正苦于以下问题:C++ Encoding::nil_p方法的具体用法?C++ Encoding::nil_p怎么用?C++ Encoding::nil_p使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::nil_p方法的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: locale_string
String* Time::locale_string(STATE, const char* data) {
String* str = String::create(state, data);
Encoding* locale = Encoding::find(state, "locale");
if(!locale->nil_p()) {
str->encoding(state, locale);
}
return str;
}
示例4:
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();
}
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: 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);
}
示例8: 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();
}
示例9: rb_enc_get_index
int rb_enc_get_index(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Object* val = env->get_object(obj);
if(!val->reference_p() && !val->symbol_p()) return -1;
Encoding* enc = Encoding::get_object_encoding(env->state(), val);
if(enc->nil_p()) return 0;
return Encoding::find_index(env->state(), enc->name()->c_str(env->state()));
}
示例10: 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);
}
示例11: 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);
}
示例12: replicate
Encoding* Encoding::replicate(STATE, const char* name, const char* original) {
Encoding* enc = find(state, original);
if(enc->nil_p()) return nil<Encoding>();
return replicate(state, name, enc);
}