问题描述
具有从 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!