C# 简体字转换繁体字代码

  1. 简体转繁体,网上其实功能有很多,我直接放上核心代码:

Microsoft.VisualBasic.Strings.StrConv(“简体转繁体”,
Microsoft.VisualBasic.VbStrConv.TraditionalChinese,0);
Microsoft.VisualBasic.Strings.StrConv(“繁体转简体”,
Microsoft.VisualBasic.VbStrConv.SimplifiedChinese, 0);

  1. 单纯使用c#,可以用API函数,代码如下:

private const int LOCALE_SYSTEM_DEFAULT = 0x0800;
private const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000;
private const int LCMAP_TRADITIONAL_CHINESE = 0x04000000;
[DllImport(“kernel32”, CharSet = CharSet.Auto, SetLastError = true)]
private static extern int LCMapString(int Locale, int dwMapFlags,
string lpSrcStr, int cchSrc, [Out] string lpDestStr, int cchDest);

发表评论