我正在使用 tinyutf8 C++ UTF-8 字符串库 https://github.com/DuffsDevice/tinyutf8
我正在尝试调用 utf8_string::find_first_of
并将 utf8_string 作为第一个参数传递。
这会产生以下错误:
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_string
中获取 char32_t*
?
或者,还有什么其他机制可以在另一个 utf8_string
中找到一个 utf8_string
?
谢谢! 肖恩
最佳答案
Shawn,目前tiny_utf8不支持find_first_of
用utf8_string
作为论据。但是,要回答您的第二个问题:您可以转换 utf8_string
到 char32_t[]
使用 utf8_string::to_wide_literal( &char32_buffer )
.
我希望这至少能有所帮助(即使您说您已经自己解决了问题,我很高兴听到这个消息 :D)。
祝一切顺利, 雅各布
关于c++ - 如何在 C++11 中使用 tinyutf8 在另一个 utf8_string 中查找 utf8_string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52340945/