Unity 获取汉字笔画数

  string chineseChar = "";
        byte[] utf8Bytes = Encoding.UTF8.GetBytes(chineseChar);
        string urlEncoded = string.Join("%", utf8Bytes.Select(b => b.ToString("X2")));

        var str = $"https://www.unicode.org/cgi-bin/GetUnihanData.pl?codepoint=%{urlEncoded}";

        var web = UnityWebRequest.Get(str);
        web.SendWebRequest();
        while (!web.isDone)
        {
           
        }

        if (web.isDone)
        {
            
        }

 

最后获取到web的text,找到【kTotalStrokes】字段 下面的数字就是笔画数,将text自行处理就好

 
posted @ 2025-01-02 18:23  减肥的程序  阅读(17)  评论(0)    收藏  举报