本文介绍了在Unicode和默认语言环境之间转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


是否有便携式(至少用于VC.Net和g ++)方法转换文件



wchar_t和char,使用标准库?我可能已经错过了很多东西

很明显,但是在Josuttis''标准C ++

图书馆中的codecvt部分没有帮助,我是还在等待Langer的交付

标准C ++ IOStreams和Locales。


谢谢,

Keith MacDonald

[snip,直接回复之前]

Hello,

Is there a portable (at least for VC.Net and g++) method to convert text
between
wchar_t and char, using the standard library? I may have missed something
obvious, but the section on codecvt, in Josuttis'' "The Standard C++
Library", did not help, and I''m still awaiting delivery of Langer''s
"Standard C++ IOStreams and Locales".

Thanks,
Keith MacDonald
[snip, before replying directly]

推荐答案




我在L& K的副本中读到没有内置支持
宽字符流
。类型''wchar_t''仅用于

来实现多字节流i / o。


另请注意,根据平台的字节大小,

并非所有Unicode值都必须符合类型

''char''。


-Mike



I read in my copy of L&K that there is no built-in support
for wide character streams. Type ''wchar_t'' is only used
to implement multibyte stream i/o.

Also note that depending upon your platform''s byte size,
not all Unicode values will necessarily fit into type
''char''.

-Mike





Mulstibyte使用多个字符来编码字符。

wchar_t是固定大小的宽字符。但我知道你的意思是什么。


是的,这是国际化支持的一个主要缺陷。

我有在comp.std.C ++游说修复此问题(将wchar_t

接口添加到极少缺乏它的几个地方

就像fstreams中的文件名等...) 。不幸的是,

我从

标准社区的其余部分得到了很多婊子和呻吟,他们没有认真对待

更有问题的字符编码如日语。



Mulstibyte is using more than one char to encode a character.
wchar_t is fixed size wide characters. But I knew what you
meant.

Yes, it''s a major defect in the internationalization support.
I have lobbied in comp.std.C++ to fix this (adding wchar_t
interfaces to the few places that are sorely lacking it
like the filenames in fstreams, etc...). Unfortunately,
I get a lot of bitching and moaning from rest of the
standard community who haven''t seriously dealt with
some of the more problematic character encodings such as Japanese.





尝试mbstowcs / wcstombs。

-

Aaron Isotton




Try mbstowcs/wcstombs.
--
Aaron Isotton
http://www.isotton.com/


这篇关于在Unicode和默认语言环境之间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:21