怎么将字符串转换为unicode编码方式

如何将字符串转换为unicode编码方式?
如题,怎么将字符串转换成为unicode编码方式?要求输入一个字符串,输出为一个unicode编码方式下得字符串.
即短字符向宽字符,转换问题,想自己写个函数实现,不使用MultiByteToWideChar,因为这个函数好象只能在MFC中可用.
各位大哥,有什么好办法,望不吝赐教,谢谢

------解决方案--------------------
setlocale(LC_ALL, "chs ");
然后mbstowcs
------解决方案--------------------
包含 <windows.h> 头文件。
#include <windows.h>
------解决方案--------------------
MultiByteToWideChar 是Windows的API, 不是MFC的东西;

mbstowcs 是C语言的函数。
------解决方案--------------------
setlocale(LC_ALL, "chs "); <==标准C语言库 函数
然后mbstowcs <=====标准C语言库 函数
------解决方案--------------------
要是跨平台就不能用api,只能用标准c了。
------解决方案--------------------
linux用
char sz[]= "b中文a ";
wchar_t xx[64]={0};
setlocale(LC_ALL, "zh_CN.gbk ");
mbstowcs( xx , sz , strlen(sz) );
win用
char sz[]= "b中文a ";
wchar_t xx[64]={0};
setlocale(LC_ALL, "chs ");
mbstowcs( xx , sz , strlen(sz) );
就 setlocale的后面一个参数系统相关了
------解决方案--------------------
up ls
------解决方案--------------------
mbstowcs

或者

mbtowc
------解决方案--------------------
mbstowcs
Converts a sequence of multibyte characters to a corresponding sequence of wide characters.


size_t mbstowcs(
wchar_t *wcstr,
const char *mbstr,
size_t count
);
Parameters
wcstr
The address of a sequence of wide characters.
mbstr
The address of a sequence of null terminated multibyte characters.
count
The maximum number of multibyte characters to convert.
Return Value
If mbstowcs successfully converts the source string, it returns the number of converted multibyte characters. If the wcstr argument is NULL, the function returns the required size of the destination string. If mbstowcs encounters an invalid multibyte character, it returns –1. If the return value is count, the wide-character string is not null-terminated.

Security Note Ensure that wcstr and mbstr do not overlap, and that count correctly reflects the number of multibyte characters to convert.
Remarks
The mbstowcs function converts up to a maximum number of count multibyte characters pointed to by mbstr to a string of corresponding wide characters that are determined by the current locale. It stores the resulting wide-character string at the address represented by wcstr. The result is similar to a series of calls to mbtowc. If mbstowcs encounters the single-byte null character ( '\0 ') either before or when count occurs, it converts the null character to a wide-character null character (L '\0 ') and stops. Thus the wide-character string at wcstr is null-terminated only if a null character is encountered during conversion. If the sequences pointed to by wcstr and mbstr overlap, the behavior is undefined.

If the wcstr argument is NULL, mbstowcs returns the required size of the destination string.

Requirements
Routine Required header Compatibility
mbstowcs <stdlib.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.