CloudBuilder.Topshelf/Task/AI/Character.md
owenchen 597b88d075 ow
2026-05-28 15:49:25 +08:00

976 B
Raw Blame History

static void Main()
{
    // 1. 生成 U+4E00 ~ U+9FA5 完整汉字合集
    List<char> cjkBasicChars = new List<char>();
    for (int code = 0x4E00; code <= 0x9FA5; code++)
    {
        cjkBasicChars.Add((char)code);
    }

    // 验证数量(应输出 20976
    Console.WriteLine($"基础区汉字总数:{cjkBasicChars.Count}");

    // 2. 输出前 10 个汉字(验证生成结果)
    Console.WriteLine("前 10 个汉字:");
    for (int i = 0; i < 10; i++)
    {
        Console.Write(cjkBasicChars[i] + " ");
    }
    // 输出:一 丁 丂 七 丄 丅 丆 万 丈 三 

    // 3. 导出为文本文件UTF-8 编码,便于查看/使用)
    string allChars = new string(cjkBasicChars.ToArray());
    File.WriteAllText("CJK_Basic_Chars.txt", allChars, System.Text.Encoding.UTF8);
    Console.WriteLine("\n已导出完整汉字集到 CJK_Basic_Chars.txt");
}