方法一:
[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);
/// <summary>
/// 將字符轉(zhuǎn)換成簡體中文
/// </summary>
/// <param name="source">輸入要轉(zhuǎn)換的字符串</param>
/// <returns>轉(zhuǎn)換完成后的字符串</returns>
public static string ToSimplified(string source) {
String target = new String(' ', source.Length);
int ret = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_SIMPLIFIED_CHINESE, source, source.Length, target, source.Length);
return target;
}
/// <summary>
/// 講字符轉(zhuǎn)換為繁體中文
/// </summary>
/// <param name="source">輸入要轉(zhuǎn)換的字符串</param>
/// <returns>轉(zhuǎn)換完成后的字符串</returns>
public static string ToTraditional(string source)
{
String target = new String(' ', source.Length);
int ret = LCMapString(LOCALE_SYSTEM_DEFAULT, LCMAP_TRADITIONAL_CHINESE, source, source.Length, target, source.Length);
return target;
}
|
新聞熱點
疑難解答
圖片精選