使用MultiByteToWideChar函数 [英] using MultiByteToWideChar function

查看:75
本文介绍了使用MultiByteToWideChar函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将c ++代码转换为c#,但是要使用以下函数MultiByteToWideChar,这是第一个参数代码页:
第一个参数在c ++中作为CP_ACP已经是ast,但是当我在c#中使用它时,据说CP_ACP在当前上下文中不存在.我在这里错过了什么?

MultiByteToWideChar(CP_ACP,0,str,-1,NULL,0);

I want to convert c++ code into c#, but with the following function MultiByteToWideChar, the first parameter codepage:
the first parameter has been ast as CP_ACP in c++, but when I use it in c#, then it is said that CP_ACP does not exist in current context. what have I missed here?

MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);

推荐答案

如果此字符串已经是UNICODE,则已经是宽字符.只要确保您在C#中的str是多字节的(可能是char数组或ASCII),而不是unicode.这样的unicode字符串只能通过WideCharToMultiByte反过来转换回多字节.
If this string is already UNICODE, then it is already wide char. Just be sure that your str in C# is multibyte (probably char array or ASCII) and not unicode. Such unicode string you may only convert back to multibyte with vice versa WideCharToMultiByte.


我认为标准.NET框架中不存在该函数,因此应使用
I do not think that function exists in the standard .NET framework, so you should use the System.Text.Encoding[^] class.


尝试使用

try using

MultiByteToWideChar(0, 0, str, -1, NULL, 0);



并让我们知道它是否仍然无法识别.



and let us know if it still doesn''t recognizes.


这篇关于使用MultiByteToWideChar函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆