Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
动态创建";LPCWSTR";std::string变量中的变量_String_Winapi_Type Conversion_Wchar - Fatal编程技术网

动态创建";LPCWSTR";std::string变量中的变量

动态创建";LPCWSTR";std::string变量中的变量,string,winapi,type-conversion,wchar,String,Winapi,Type Conversion,Wchar,目前我有代码(typedef\u Null\u terminated\u CONST WCHAR*LPCWSTR;): 但需要启用类似这样的功能: std::string s("ABC"); ... LPCWSTR wchar_string(/* create somehow from variable s */); std::string是一个8位字符串wchar_字符串是一个宽(UTF-16)代码点数组。根据定义,这需要进行代码转换操作,而不仅仅是一个简单的赋值 首先,8位字符串是如何编码

目前我有代码(
typedef\u Null\u terminated\u CONST WCHAR*LPCWSTR;
):

但需要启用类似这样的功能:

std::string s("ABC");
...
LPCWSTR wchar_string(/* create somehow from variable s */);

std::string
是一个8位字符串
wchar_字符串
是一个宽(UTF-16)代码点数组。根据定义,这需要进行代码转换操作,而不仅仅是一个简单的赋值

首先,8位字符串是如何编码的?是UTF-8、Windows ANSI“当前代码页”、仅拉丁语-1还是什么

其次,调用类似Windows的函数来完成繁重的工作,并确保为wchar_字符串所指向的结果缓冲区管理内存

std::string s("ABC");
...
LPCWSTR wchar_string(/* create somehow from variable s */);