急!·求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);
[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);
...全文
相关推荐
vc在GB码和Big5码间转换字符编码转换
vc在GB码和Big5码间转换字符编码转换"的主题涉及到两个主要的中文编码标准:GB码(GBK)和Big5码,以及如何在它们之间进行转换。
Visual Studio Code运行程序时输出中文成乱码问题及解决方法
VS Code默认使用UTF-8编码,而某些情况下,程序的输出或者文件本身可能使用了不同的编码,如GBK,导致中文字符无法正确显示。
VC字符串转换的常用方法
**注意事项**: - 转换时需注意字符编码问题,不同的字符串可能采用不同的编码,如ASCII、UTF-8、GBK等,不正确的编码转换可能导致乱码。
epson 热敏打印机 打印 源码
对于汉字等非ASCII字符,可能需要使用GB2312、GBK或者Unicode编码,并将其转换为字节流。同时,图像数据通常需要先转化为位图,再编码成打印机可识别的格式。4.
VS2008中自定义C++工程模板.pdf
**修改新建文件的默认编码** - **问题提出**:默认情况下,VS2008在Windows下的编码格式是GB2312,这对于需要在Linux环境下查看和编辑代码的用户来说不太友好。


