代码之家  ›  专栏  ›  技术社区  ›  Alexander

从C#字符串检测使用过的写入系统

  •  0
  • Alexander  · 技术社区  · 7 年前

    考虑由用户提供的输入字符串,包含至少一个字符来自一个书写系统(例如拉丁语、西里尔语、希腊语、阿拉伯语、希伯来语、汉语、日语、韩语……)。

    是否有可能检测到使用了哪种书写系统?我需要先进行一些Unicode解码,然后再进行Unicode页面,还是有一些函数可以帮我做到这一点?

    2 回复  |  直到 7 年前
        1
  •  0
  •   Mikev    7 年前

    您可以尝试使用google API检测语言: here

    所有的学分和如何使用它 here !

        2
  •  0
  •   NaDeR Star    7 年前

    public static class StringExtension
    {
        public static bool IsUnicodeCharacterInIt(this string value)
        {
            return value.Any(c => c > 255);
        }
    }
    
    public void Check()
    {
        var unicodeString = "سلام بیبی";
        var nonUnicodeString = "hi baby";
    
        var result1 = unicodeString.IsUnicodeCharacterInIt();
        var result2 = nonUnicodeString.IsUnicodeCharacterInIt();
    }