首页 > 学院 > 开发设计 > 正文

繁體簡體相互轉化

2019-11-17 02:13:09
字体:
来源:转载
供稿:网友

繁體簡體相互轉化

Posted on 2015-07-29 16:32 qhy1277 阅读(...) 评论(...) 编辑 收藏

ublic partial class Common { /// <summary> /// 繁簡轉換 /// </summary> /// <param name="locale"></param> /// <param name="dwMapFlags"></param> /// <param name="lpSrcStr"></param> /// <param name="cchSrc"></param> /// <param name="lpDestStr"></param> /// <param name="cchDest"></param> /// <returns></returns> [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); private const int _LOCALESYSTEMDEFAULT = 0x0800; private const int _LCMAPSIMPLIFIEDCHINESE = 0x02000000; private const int _LCMAPTRADITIONALCHINESE = 0x04000000;

/// <summary> /// 繁轉簡 /// </summary> /// <param name="argSource"></param> /// <returns></returns> public static string TranslateSimplified(string argSource) { var t = new String(' ', argSource.Length); LCMapString(_LOCALESYSTEMDEFAULT, _LCMAPSIMPLIFIEDCHINESE, argSource, argSource.Length, t, argSource.Length); return t; }

/// <summary> /// 簡轉繁 /// </summary> /// <param name="argSource"></param> /// <returns></returns> public static string TranslateTraditional(string argSource) { var t = new String(' ', argSource.Length); LCMapString(_LOCALESYSTEMDEFAULT, _LCMAPTRADITIONALCHINESE, argSource, argSource.Length, t, argSource.Length); return t; } }


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表