给定目标编码时如何将 wint_t 转换为 char? [英] How to convert wint_t to char when given the target encoding?

查看:23
本文介绍了给定目标编码时如何将 wint_t 转换为 char?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有从 getwc(fh) 获得的 wint_t Unicode 代码点.使用Windows函数,当我知道目标编码时如何将其转换为窄char?我知道可以使用 8 位编码(比如 windows-1250)来表示该字符.

Having wint_t Unicode code point got from the getwc(fh). Using Windows functions, how can I convert it to the narrow char when I know the target encoding? I know that the character can be represented using the 8-bit encoding (say windows-1250).

WideCharToMultiByte()函数相比,有没有类似的函数可以转换单个宽字符而不是字符串?应该如何正确完成?

Compared with the WideCharToMultiByte() function, is there a similar function to convert a single wide character instead of the string? How it should be done correctly?

这个问题与我的如何处理某些元素中带有空字符的 CSV 行?

推荐答案

按照设计,没有等效的功能.您错误地认为甚至可以逐个字母地转换.这与将英语一个字母一个字母地翻译成法语一样不可能——它只是行不通.

There's no equivalent function, by design. You're mistakingly assuming it's even possible to convert letter by letter. That's about as impossible as translating English to French letter by letter - it just doesn't work that way.

这篇关于给定目标编码时如何将 wint_t 转换为 char?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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