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