Files
29WxOrder/AllBase/Util/ChineseStringConverter.cs
wule_5900x ac93305d5f 1 修复淘宝拍单窗口可能崩溃问题
2 拼多多中转仓拍单随机地址支持随机繁体字
2026-11-07 22:35:03 +08:00

32 lines
985 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace AllBase.Util;
public class ChineseStringConverter
{
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);
public static string ToSimplified(string source)
{
string target = new string(' ', source.Length);
LCMapString(0x0800, LCMAP_SIMPLIFIED_CHINESE, source, source.Length, target, source.Length);
return target;
}
public static string ToTraditional(string source)
{
string target = new string(' ', source.Length);
LCMapString(0x0800, LCMAP_TRADITIONAL_CHINESE, source, source.Length, target, source.Length);
return target;
}
}