急!·求C#中获得字的GB或者GBK编码的方法,在C#求UNICODE码很简单,在VC中求字的任何编码我都已经实现了,但在C#中由于默认是以UNICODE

gyjjcumt gyjjcumt 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
急!·求C#中获得字的GB或者GBK编码的方法,在C#求UNICODE码很简单,在VC中求字的任何编码我都已经实现了,但在C#中由于默认是以UNICODE编码,不知道如何在C#中求字的GB或GBK编码?谢谢!

[DllImport("kernel32",CharSet=CharSet.Unicode,EntryPoint="WideCharToMultiByte",SetLastError=true)]
public static extern int WideCharToMultiByte1(
uint CodePage, // code page
uint dwFlags, // performance and mapping flags
[MarshalAs(UnmanagedType.LPWStr)]
string lpWideCharStr, // wide-character string
int cchWideChar, // number of chars in string
[MarshalAs(UnmanagedType.LPStr)]
ref string lpMultiByteStr, // buffer for new string
//StringBuilder lpMultiByteStr, // buffer for new string
int cbMultiByte, // size of buffer
string lpDefaultChar, // default for unmappable chars
object lpUsedDefaultChar // set when default char used
);


********************************************调用**
szW="啊";
int sii=WideCharToMultiByte1(0x936,0, szW,6,out szM,4,dd, null);
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
gyjjcumt
C# 111,128 成员 642,536 内容