如题 要调用一个dll dll使用的GBK 返回的也是 GBK 如何转换unicode
解决方案 »
- 限制鼠标活动区域帮忙解释解释程序 看不懂了
- c#连接ACCESS 2003数据库(oledb)的连接字符串报错
- 定义了一个byte[]型的数组.但我可能用不到那么大长度.如何把多余的去掉
- 读取数据库中某一时间段内某一字段的sum,并返回sum值
- 单击DataGridView获取某个单元格的值
- ★★★★水晶报表调RefreshReport()参数丢失的问题
- C#接口实现问题
- 为啥我的session不能保存数据啊
- 下面的为何会错误?
- 如何添加对话框?
- ---- 架在自己电脑上的网页,速度太慢,怎样解决?--- 100 分相谢-----
- @@@@@@@@@@@@@给一个十进制数,如何知道他的十六进制的高位和低位?@@@@@@@@@@@@@@@@
能具体点不?
encoding 的2个参数 含义
using System.Text;namespace ConvertExample
{
class ConvertExampleClass
{
static void Main()
{
string unicodeString = "This string contains the unicode character Pi(\u03a0)"; // Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode; // Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString); // Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
// Convert the new byte[] into a char[] and then into a string.
// This is a slightly different approach to converting to illustrate
// the use of GetCharCount/GetChars.
char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
string asciiString = new string(asciiChars); // Display the strings created before and after the conversion.
Console.WriteLine("Original string: {0}", unicodeString);
Console.WriteLine("Ascii converted string: {0}", asciiString);
}
}
}
如何获得 encoding GBK
如何获得 encoding GBK如果要获得string来说,转换是没有什么意义的。你说说具体要做什么吧
我调用dll 返回的个parm是个GBK的string 现在想把他转换成 unicode
这样可以正确显示出来
parm 在gbk 得到的是 簨[W騗蟸
unicode是 论坛已经开通,请到www.webp2p.com/bbs去提问,每天有人执班。
如何转换
还是不行
byte[] bData = Encoding.GetEncoding(936).GetBytes(parm);
bData = Encoding.Convert( Encoding.GetEncoding(936), Encoding.Unicode, bData );
string strValue = Encoding.Unicode.GetString( bData );Method2:
http://blog.csdn.net/knight94/archive/2006/05/01/704645.aspx
PWSTR pUnicode; //指向转换结果
//取转换之后的UNICODE字符长度
int iLength = MultiByteToWideChar (CP_ACP, 0, pGBK, -1, NULL, 0) ;
pUnicode = malloc(iLength);
//转换结束
MultiByteToWideChar (CP_ACP, 0, pGBK, -1, pUnicode, iLength)
free(pUnicode);