Windows API ANSI函数和UTF-8 [英] Windows API ANSI functions and UTF-8

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

问题描述

可以使用带有UTF-8字符串的Windows API ANSI函数吗?



例如,假设我有一个以UTF-8编码的路径。可以调用 CreateDirectoryA CreateFileA 并使用UTF-8路径,或者在调用之前必须执行一些转换函数?

解决方案

否。使用 MultiByteToWideChar 将UTF-8转换为UTF-16,然后调用宽字符API,例如 CreateDirectoryW CreateFileW 。 p>

Is it possible to use Windows API ANSI functions with UTF-8 strings?

For example, say I have a path encoded in UTF-8. Can I call CreateDirectoryA or CreateFileA and use a UTF-8 path, or do I have to perform some conversion before calling the functions?

解决方案

No. Use MultiByteToWideChar to convert UTF-8 to UTF-16 and then call the wide character APIs such as CreateDirectoryW or CreateFileW.

这篇关于Windows API ANSI函数和UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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