Multibytetowidechar逻辑问题 [英] Multibytetowidechar logic problem
问题描述
使用
以下方法将一些ansi希伯来字符串转换为unicode字符串:
nSize = MultiByteToWideChar(nlanguageCodePage,0,chAnsiBuff,-1,NULL,0);
MultiByteToWideChar(nlanguageCodePage,0,chAnsiBuff,-1,chUniocodeBuff,512); < br $> b $ b
我有希伯来语 - (Windows代码页1255)所以我会得到1255 ....如果ansi中有任何垃圾字符它会消除unicode中的相关性吗?
这究竟是做什么的(即如果我将指定希伯来语仍将其转换为第一个参数将会执行)
请让我知道为什么它不工作
我尝试过:
iam converting some ansi hebrew string to unicode string by using
following method:
nSize = MultiByteToWideChar(nlanguageCodePage, 0, chAnsiBuff, -1, NULL, 0);
MultiByteToWideChar(nlanguageCodePage, 0, chAnsiBuff, -1, chUniocodeBuff, 512);
iam having hebrew - ( windows code page 1255) so i will get 1255 ....if any junk characters are there in ansi it will dispalay correclty in unicode ?
what exactly this will do ( i.e first parameter will do if i willspecify hebrew still its converting proeprly)
please let me know the why its not working
What I have tried:
//CONVERTING TO UNICODE
nSize = MultiByteToWideChar(nlanguageCodePage, 0, chAnsiBuff, -1, NULL, 0);
MultiByteToWideChar(nlanguageCodePage, 0, chAnsiBuff, -1, chUniocodeBuff, 512);
// bom at starting
if (nBOM == 0) { arcOut.Write(&bom, 2); }
arcOut.WriteString(chUniocodeBuff);
推荐答案
该函数用于转换多字节字符串进入宽字符字符串。阅读 MultiByteToWideChar 功能的文档总是一个好主意。
但是当输入 ANSI 时,你最好阅读如何:在各种字符串类型之间进行转换以了解不同的字符串类型。简短:ANSI-char是单字节char,但Multibyte和wide char最多可以是4个字节。因此,请注意使用sizeof-operator和一些字符串长度函数时的区别。转换之前一定要检查尺寸!始终; - )
The function is for converting Multibyte string into wide char strings. Reading the documentation of the MultiByteToWideChar function is always a good idea.
But when your input is ANSI you better read the How to: Convert Between Various String Types to understand the different string types. A short: a ANSI-char is a single byte char, but the Multibyte and wide char can be up to four bytes. So be aware of the difference when using the sizeof-operator and some string length functions. Always check sizes before converting!!! Always ;-)
这篇关于Multibytetowidechar逻辑问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!