本文整理汇总了C++中Encoding::name方法的典型用法代码示例。如果您正苦于以下问题:C++ Encoding::name方法的具体用法?C++ Encoding::name怎么用?C++ Encoding::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encoding
的用法示例。
在下文中一共展示了Encoding::name方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
ReloadEncodingDialog::ReloadEncodingDialog(TextEdit* textEdit,
const Encoding& fromEncoding,
const Encoding& toEncoding,
QWidget* parent)
: QDialog(parent),
m_fromEncoding(fromEncoding),
m_toEncoding(toEncoding),
m_textEdit(textEdit) {
QPushButton* cancelBtn = new QPushButton(tr("&Cancel"));
QPushButton* reloadBtn = new QPushButton(tr("&Reload"));
QPushButton* convertBtn = new QPushButton(tr("&Convert"));
auto buttonBox = new QDialogButtonBox(this);
// The button box takes ownership of the button
buttonBox->addButton(reloadBtn, QDialogButtonBox::ActionRole);
buttonBox->addButton(convertBtn, QDialogButtonBox::ActionRole);
buttonBox->addButton(cancelBtn, QDialogButtonBox::ResetRole);
auto label = new QLabel(
tr("Reload: reload current file from disk in %1\nConvert: convert current text in %1")
.arg(toEncoding.name()),
this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(label);
layout->addWidget(buttonBox, 0, Qt::AlignRight);
setLayout(layout);
setWindowTitle(tr("%1: Reload or Convert to %2").arg(fromEncoding.name()).arg(toEncoding.name()));
setFixedHeight(sizeHint().height());
connect(cancelBtn, &QPushButton::clicked, this, &ReloadEncodingDialog::close);
connect(reloadBtn, &QPushButton::clicked, this, &ReloadEncodingDialog::reload);
connect(convertBtn, &QPushButton::clicked, this, &ReloadEncodingDialog::convert);
}
示例2: init
void Encoding::init(STATE) {
onig_init(); // in regexp.cpp too, but idempotent.
Class* enc = ontology::new_class_under(state, "EncodingClass", G(rubinius));
GO(encoding).set(ontology::new_class_under(state, "Encoding", enc));
G(encoding)->set_object_type(state, EncodingType);
enc->set_const(state, "EncodingMap", LookupTable::create(state));
enc->set_const(state, "EncodingList", Array::create(state, 3));
G(encoding)->set_ivar(state, state->symbol("@default_external"), G(undefined));
G(encoding)->set_ivar(state, state->symbol("@default_internal"), G(undefined));
Encoding* ascii = create_bootstrap(state, "US-ASCII", eAscii, ONIG_ENCODING_US_ASCII);
Encoding* binary = create_bootstrap(state, "ASCII-8BIT", eBinary, ONIG_ENCODING_ASCII);
Encoding* utf8 = create_bootstrap(state, "UTF-8", eUtf8, ONIG_ENCODING_UTF_8);
ascii->name(state, String::create(state, "US-ASCII"));
binary->name(state, String::create(state, "ASCII-8BIT"));
utf8->name(state, String::create(state, "UTF-8"));
#include "vm/gen/encoding_database.cpp"
int index = -1;
char* locale_charmap;
#ifdef HAVE_NL_LANGINFO
setlocale(LC_CTYPE, "");
locale_charmap = nl_langinfo(CODESET);
#else
locale_charmap = "US-ASCII";
#endif
enc->set_const(state, "LocaleCharmap", String::create(state, locale_charmap));
index = find_index(state, locale_charmap);
if(index < 0) index = find_index(state, "US-ASCII");
create_internal(state, "locale", index);
create_internal(state, "external", index);
create_internal(state, "filesystem", index);
create_internal(state, "internal", -1);
Transcoding::init(state);
Converter::init(state);
}
示例3:
void Encoding::Info::show(STATE, Object* self, int level) {
Encoding* enc = as<Encoding>(self);
class_header(state, self);
indent_attribute(++level, "name"); enc->name()->show_simple(state, level);
indent_attribute(level, "dummy?"); enc->dummy()->show_simple(state, level);
close_body(level);
}
示例4: define
Encoding* Encoding::define(STATE, const char* name,
OnigEncodingType* enc, Object* dummy)
{
Encoding* e = create(state, enc, dummy);
e->name(state, String::create(state, name));
symbol_map(state)->store(state, state->symbol(name), e);
add_constant(state, name, e);
return e;
}
示例5: 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()));
}
示例6: define
Encoding* Encoding::define(STATE, const char* name,
OnigEncodingType* enc, Object* dummy)
{
Encoding* e = create(state, enc, dummy);
e->name(state, String::create(state, name));
Array* list = encoding_list(state);
size_t index = list->size();
Tuple* ref = encoding_reference(state, index);
encoding_map(state)->store(state, encoding_symbol(state, name), ref);
list->set(state, index, e);
add_constant(state, name, e);
return e;
}
示例7: rb_to_encoding_index
int rb_to_encoding_index(VALUE obj) {
NativeMethodEnvironment* env = NativeMethodEnvironment::get();
Encoding* enc;
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->name()->c_str(env->state()));
}
示例8: init
void Encoding::init(STATE) {
onig_init(); // in regexp.cpp too, but idempotent.
Class* enc = ontology::new_class_under(state, "Encoding", G(rubinius));
enc->name(state, state->symbol("Rubinius::Encoding"));
GO(encoding).set(ontology::new_class_under(state, "Encoding", enc));
G(encoding)->set_object_type(state, EncodingType);
G(encoding)->name(state, state->symbol("Encoding"));
enc->set_const(state, "SymbolMap", LookupTable::create(state));
enc->set_const(state, "IndexMap", LookupTable::create(state));
Encoding* ascii = create_bootstrap(state, "US-ASCII", eAscii, ONIG_ENCODING_ASCII);
Encoding* utf8 = create_bootstrap(state, "UTF-8", eUtf8, ONIG_ENCODING_UTF_8);
ascii->name(state, String::create(state, "US-ASCII"));
utf8->name(state, String::create(state, "UTF-8"));
#include "vm/gen/encoding_database.cpp"
}