如何从 c++ 或 cocos2dx 中的表情符号中获取 unicode
How to get the unicode from a emoji in c++ or cocos2dx?
如果我有像" "这样的表情符号,在代码中是:
std::string emojiStr = " ";
在网站上,表格显示了这个表情符号的 unicode,如"U+1F31E"
请教我如何从 c++/cocos2dx 中的字符串" "中获取这个 unicode?
首先,谢谢你的回答,谢夫!
我在 https://en.cppreference.com/w/cpp/locale/codecvt 中找到了这个例子,并写了一个我所看到的愚蠢的方法。但它毕竟可以工作。
这是代码:
std::string EWUtils::emojiToStr(std::string str)
{
std::ofstream(FileUtils::getInstance()->fullPathForFilename("text.txt")) << str;
std::wifstream fin(FileUtils::getInstance()->fullPathForFilename("text.txt"));
fin.imbue(std::locale("en_US.UTF-8"));
std::string name;
for (wchar_t c; fin >> c; )
{
__String* item = __String::createWithFormat("%x",c);
name = name + item->_string + "-";
}
if (name.length() > 1) {
name.pop_back();
}
return name;
}
我知道真的没有必要将字符串写入 txt 文件。但如果示例这样写,我就遵循它。
我真的是一个初学者。如果有人有更好的方法,欢迎展示。
相关文章:
- 获取隐式转换溢出从无符号到已签名的警告
- 如何从二进制文件中的给定符号中获取调用程序图
- 使用jsoncpp-NuGet包时获取未解析的外部符号
- 获取未定义的符号:尝试使用Clang地址清理器时__asan_memset
- 获取 constexpr 全局变量(不是静态成员)的链接器符号
- 获取两个无符号整数 C++ 乘积的高 32 位的有效方法
- 在C 中获取Ncurses Chtype或未符号字符的整数值
- 尝试将返回无符号值的函数分配给指向无符号的指针时,继续获取 SIGSEGV
- 使用字符时获取 ╠ 符号 'e'
- 在C++中以字符串形式获取ECL符号名称
- 如何从 c++ 或 cocos2dx 中的表情符号中获取 unicode
- 获取有关 ELF 中的函数和相关符号的信息
- 如何按位获取数字而不是求反符号位
- 从文件输入中获取奇怪的符号
- OSX "ld" : 如何显示未解析符号的损坏名称?如何获取地图文件?
- 如何获取标准 C/C++ 中的文件分隔符符号:/ 或 \
- 获取在GDB便利性变量中持有的价值的符号信息
- 在Python中获取从有符号整数到无符号整数的转换
- 获取网站来源,获取额外的符号,winsock
- 为不明确的符号获取错误,需要帮助将其删除