Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何使用C+中的tinyutf8在另一个utf8#u字符串中查找utf8#u字符串+;11?_C++_String_C++11_Unicode_Utf 8 - Fatal编程技术网

C++ 如何使用C+中的tinyutf8在另一个utf8#u字符串中查找utf8#u字符串+;11?

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

我使用的是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);
^
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字符串

谢谢!
Shawn

Shawn,当前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字符串参数。