方法一:
[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>
/// 将字符转换成简体中文
/// </summary>
/// <param name="source">输入要转换的字符串</param>
/// <returns>转换完成后的字符串</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>
/// 讲字符转换为繁体中文
/// </summary>
/// <param name="source">输入要转换的字符串</param>
/// <returns>转换完成后的字符串</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;
}
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论