gpt4 book ai didi

c++ - 从 C++ 中的 unicode 字符串检测语言环境

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:39:17 24 4
gpt4 key购买 nike

我有一个字符串,我想检查内容是英语还是印地语(我的本地语言)。我发现印地文字符的 unicode 范围是从 U0900-U097F。

查找字符串是否包含此范围内的任何字符的最简单方法是什么?

我可以根据方便使用 std::string 或 Glib::ustring。

最佳答案

这里是你如何用 Glib::ustring 做到这一点:

using Glib::ustring;

ustring x("सहस"); // hindi string
bool is_hindi = false;
for (ustring::iterator i = x.begin(); i != x.end(); i ++)
if (*i >= 0x0900 && *i <= 0x097f)
is_hindi = true;

关于c++ - 从 C++ 中的 unicode 字符串检测语言环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1288009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com