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; } }
新闻热点
疑难解答