本文介绍了将ASCII字符串转换为Unicode吗? Windows,纯C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了使用Windows API的许多编程语言(C语言除外)的答案.没有C ++的答案.请考虑以下内容:

I've found answers to this question for many programming languages, except for C, using the Windows API. No C++ answers please. Consider the following:

#include <windows.h>
char *string = "The quick brown fox jumps over the lazy dog";
WCHAR unistring[strlen(string)+1];

我可以使用什么功能用 string 中的字符填充 unistring ?

What function can I use to fill unistring with the characters from string?

推荐答案

MultiByteToWideChar :

#include <windows.h>
char *string = "The quick brown fox jumps over the lazy dog";
size_t len = strlen(string);
WCHAR unistring[len + 1];
int result = MultiByteToWideChar(CP_OEMCP, 0, string, -1, unistring, len + 1);

这篇关于将ASCII字符串转换为Unicode吗? Windows,纯C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 19:19