C++ 如何使用C+中的tinyutf8在另一个utf8#u字符串中查找utf8#u字符串+;11?
我使用的是TyyUutf8 C++ +UTF-8字符串库 我试图调用C++ 如何使用C+中的tinyutf8在另一个utf8#u字符串中查找utf8#u字符串+;11?,c++,string,c++11,unicode,utf-8,C++,String,C++11,Unicode,Utf 8,我使用的是TyyUutf8 C++ +UTF-8字符串库 我试图调用utf8\u字符串::find\u first\u of传递一个utf8\u字符串作为第一个参数 这将生成以下错误: error: no matching function for call to ‘utf8_string::find_first_of(utf8_string&, int&)’ int found_pos = haystack.find_first_of(needle, at_pos); ^ I
utf8\u字符串::find\u first\u of
传递一个utf8\u字符串作为第一个参数
这将生成以下错误:
error: no matching function for call to ‘utf8_string::find_first_of(utf8_string&, int&)’
int found_pos = haystack.find_first_of(needle, at_pos);
^
In file included from Phonemizer.cpp:8:0:
tinyutf8.h:1728:12: note: candidate: utf8_string::size_type utf8_string::find_first_of(const value_type*, utf8_string::size_type) const
size_type find_first_of( const value_type* str , size_type start_codepoint = 0 ) const ;
^~~~~~~~~~~~~
tinyutf8.h:1728:12: note: no known conversion for argument 1 from ‘utf8_string’ to ‘const value_type* {aka const char32_t*}’
如何从我的utf8\u字符串中获取char32\u*
?
或者,还有什么其他机制可以在另一个utf8\u字符串中查找utf8\u字符串
谢谢!
ShawnShawn,当前tiny_utf8不支持以utf8_字符串作为参数的find_first_of
。但是,要回答第二个问题:您可以使用utf8\u字符串::to\u wide\u literal(&char32\u buffer)
将utf8\u字符串
转换为char32\t[]
我希望这至少有一点帮助(尽管你说你自己已经解决了这个问题,我很高兴听到:D)
祝你一切顺利,
Jakob如果你不特别,你可以搜索字节序列。标准库有很多查找函数。如果您有特殊要求,您必须使用库将搜索字符串和文本转换为Unicode的标准格式,以确保像“é”(例如)这样的字符表示为相同的代码点序列。感谢@Alf提供的有用意见。我开始做字节序列搜索,得到一个原始迭代器并返回到一个代码点索引,但后来我意识到我可以使用find代替find,find首先接受一个utf8字符串参数。