如何在 C++11 中使用 tinyutf8 在另一个utf8_string中找到utf8_string?
How to find utf8_string in another utf8_string using tinyutf8 in C++11?
我正在使用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::to_wide_literal( &char32_buffer )
将utf8_string
转换为char32_t[]
。
我希望这至少有一点帮助(即使您说您自己已经解决了问题,我很高兴听到:D(。
万事如意, 雅 各 布
相关文章:
- cppcheck在const std::string[]上引发警告
- 将std::string传递给WriteConsole API
- 为std::string的某个索引赋值
- std中有类似find_last_of的函数,而string中没有
- 使用 std::string () const 函数启动线程或未来
- 使用char类型将decimal转换为string,将string转换为decimal
- 迭代和比较映射<字符串、矢量<string>> c++ 中的值
- 当我们进行一些操作时,应该使用什么'std::string'或'std::stringstream'?
- 将向量解析<string>为字符串
- 'string.assign(string.data(), 5)' 是明确定义的还是 UB?
- C ++如何使用UTF8十六进制代码打印UTF8符号?
- 如何更改大小(std::string)
- 将utf16宽std::wstring转换为utf8窄std::string以获得罕见字符时出现问题
- 如何检查包含 utf8 文本的 std::string 在 Windows 中是否以大写字母开头?
- 如何将 UTF8 std::string 转换为 NSString
- UTF8 数据到 std::string 或 std::wstring
- 如何将 UTF8 转换为 std::string
- 如何将 utf16 ushort 数组转换为 utf8 std::string
- std::string, std::wstring and UTF8
- 从本地<String>计算一行中的 UTF8 字符