c++ - 如何在 C++11 中使用 tinyutf8 在另一个 utf8_string 中查找 utf8_string?

标签 c++ string c++11 unicode utf-8

我正在使用 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_ofutf8_string作为论据。但是,要回答您的第二个问题:您可以转换 utf8_stringchar32_t[]使用 utf8_string::to_wide_literal( &char32_buffer ) .

我希望这至少能有所帮助(即使您说您已经自己解决了问题,我很高兴听到这个消息 :D)。

祝一切顺利, 雅各布

关于c++ - 如何在 C++11 中使用 tinyutf8 在另一个 utf8_string 中查找 utf8_string?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52340945/

相关文章:

c++ - 在 OpenGL 中清除场景和刷新变量

C++ : Array of struct as function parameter

java - Scala - 运行时字符串模板

c - 以字符串形式获取输入并打印

c++ - 在内部类中使用引用模板参数

Qt C++11 lambda : Is this connect (signal-slot) correct?

c++ - HKEY 句柄为 NULL,在调试期间它写入未使用的<无法读取内存>

C++ 互斥锁定错误

PHP - 从字符串中删除 <img> 标签

c++ - 缓冲区填充不同类型的数据,并严格别名