本文整理汇总了C++中ustring::bytes方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::bytes方法的具体用法?C++ ustring::bytes怎么用?C++ ustring::bytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ustring
的用法示例。
在下文中一共展示了ustring::bytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: equals
/* Check if input and last word is the same.
* @param: ustring last_word - Ustring representation of the string last written by the user.
* @return: int - Returns 0 on equal w/kanji, returns 1 on equal w/kana only, returns 2 on false w/kanji, returns 3 on false w/kana only.
*/
int Mode_eng_jap::equals(ustring lword)
{
if (kana(lword)) {
ustring last_wd = last->get_wd2();//Get last corret word hir/kat
if (lword.bytes() != last_wd.bytes()) return 3;
const char* u_c_str = lword.c_str();
const char* l_cor_c_str = last_wd.c_str();
int place;
for (place = 0; (unsigned int) place < lword.bytes(); place++) {
if (u_c_str[place] != l_cor_c_str[place]) return 3;
}
return 1;
} else {
ustring last_wd_kji = last->get_wd2_alt(); //Get last corret Kanji
if (lword.bytes() != last_wd_kji.bytes()) return 2;
cout << "Checking Kanji" << endl;
const char* u_c_str = lword.c_str();
const char* l_cor_kji = last_wd_kji.c_str();
int place;
for (place = 0; (unsigned int) place < last_wd_kji.bytes(); place++) {
if (u_c_str[place] != l_cor_kji[place]) return 2;
}
return 0;
}
}
示例2: kana
/* Check if the in string contains kana characters only.
* @param: ustring last_word - Ustring representation of the string last written by the user.
* @return: boolean - contains only kana.
*/
bool Mode_eng_jap::kana(ustring lword)
{
if ((lword.bytes()) % 3 == 0){
const char * larr = lword.c_str();
int x;
for (x = 0; (unsigned int) x < lword.bytes(); x += 3) {
if ( ((int) larr[x]) != -29) return false;
}
return true;
}
return false;
}
示例3: parseStrList
void DataValue::parseStrList(const ustring &text, void *value) {
int l = text.bytes();
char *buf = new char[l+1], *sb = buf;
strcpy(buf, text.c_str());
if(*buf == '#') {
buf++;
if(*buf) {
StringList list;
do {
int n = atoi(getTok(&buf, ':'));
ustring s = ustring(buf, n);
list << s;
buf += s.bytes(); // data
buf ++; // | delimiter
} while(*buf);
*(ustring *)value = list;
}
else
*(ustring *)value = "";
}
else {
*(ustring *)value = buf;
}
delete sb;
}
示例4: setText
void StringList::setText(const ustring &text)
{
char *buf = new char[text.bytes() + 1], *sbuf = buf;
strcpy(buf, text.c_str());
loadFromChar(buf);
delete[] sbuf;
}
示例5: parseFont
void DataValue::parseFont(const ustring &text, void *value) {
int l = text.bytes();
char *buf = new char[l+1], *sb = buf;
strcpy(buf, text.c_str());
buf++;
((FontRecord*)value)->name = getTok(&buf, ',');
((FontRecord*)value)->size = atoi(getTok(&buf, ','));
((FontRecord*)value)->style = atoi(getTok(&buf, ','));
((FontRecord*)value)->color = atoi(getTok(&buf, ','));
((FontRecord*)value)->charset = atoi(getTok(&buf, ']'));
delete sb;
}