MinGW编译器,ANSI-Win32程序,UTF-8代码:乱码 Topic is solved

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
Loaden
I live to help wx-kind
I live to help wx-kind
Posts: 177
Joined: Tue Feb 19, 2008 10:21 am
Location: China

MinGW编译器,ANSI-Win32程序,UTF-8代码:乱码

Post by Loaden » Sat Dec 20, 2008 2:52 am

请问如何解决?MinGW4.3.2,开发一个ANSI(不支持Unicode,因为要在Win9x下使用,而且不想使用MSLU),源代码使用UTF-8格式保存(不使用ANSI)。

怎么解决?

目前想到:可以把源代码格式改为GBK编码,并且使用-finput_charset=gbk来解决。但这不是我想要的。

有更好的解决方案吗?如果改用wx2.9SVN版本呢?是否内置了UTF-8的解决?但Windows编程又如何支持UTF-8显示呢?
Life is not fair, get used to it.

Utensil
Moderator
Moderator
Posts: 423
Joined: Sun Feb 03, 2008 11:38 am
Location: China

Post by Utensil » Sun Dec 21, 2008 4:56 pm

2.8也是支持utf-8的,2.9只是变得骨头里都支持而已。

我一般是写英语的界面,然后国际化...呵呵~

-Utensil
In fascination of creating worlds by words, and in pursuit of words behind the world.

On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/

Loaden
I live to help wx-kind
I live to help wx-kind
Posts: 177
Joined: Tue Feb 19, 2008 10:21 am
Location: China

Post by Loaden » Mon Dec 22, 2008 5:04 am

不知道版主是否研究过Windows下如何支持UTF-8?
我觉得根本无法解决。Windows编码或者ANSI(Win9x时代),或者Unicode,又如何实现UTF-8的显示呢。

编译过一次wx2.9svn,发现其默认就是UTF-8编码:那在Win9x下怎么办?
Life is not fair, get used to it.

Utensil
Moderator
Moderator
Posts: 423
Joined: Sun Feb 03, 2008 11:38 am
Location: China

Post by Utensil » Mon Dec 22, 2008 6:37 am

不好意思,我之前没有看清楚你的问题~要在9x下运行啊~

我之前看到过一个英文帖子,是同样的问题。解决方案就是wxWidgets的UNICODE Build加上MSLU那个dll就可以了。

那个提问者也是不肯用MSLU...不过我始终不明白为什么...

-Utensil
In fascination of creating worlds by words, and in pursuit of words behind the world.

On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/

Loaden
I live to help wx-kind
I live to help wx-kind
Posts: 177
Joined: Tue Feb 19, 2008 10:21 am
Location: China

Post by Loaden » Mon Dec 22, 2008 3:14 pm

MSLU存在一些未知的问题,程序运行具有不确定因素。而且链接必须加-static链接参数,然后有些API不支持,比如Module32FirstW。
我也尝试过用MSLU,但在98下调试时发现一些API明明调用成功,却返回0(错误),比如GetModuleName(好像记错API名称了)。

我尝试MSLU支持来编译Code::Blocks SVN 5344,发现根本无法编译成功。
这可能也可以证明MSLU的局限性。所以不敢用了。
Life is not fair, get used to it.

Loaden
I live to help wx-kind
I live to help wx-kind
Posts: 177
Joined: Tue Feb 19, 2008 10:21 am
Location: China

Post by Loaden » Sat Jan 10, 2009 12:20 pm

如果源代码是UTF-8格式,则编译时每个汉字占三个char,所以不可能在ANSI程序中正常显示。除非:调用MultiByteToWideChar、WideCharToMultiByte进行转换。
Life is not fair, get used to it.

Loaden
I live to help wx-kind
I live to help wx-kind
Posts: 177
Joined: Tue Feb 19, 2008 10:21 am
Location: China

Post by Loaden » Sat Jan 10, 2009 12:21 pm

如果源代码是UTF-8格式,则编译时每个汉字占三个char,所以不可能在ANSI程序中正常显示。除非:调用MultiByteToWideChar、WideCharToMultiByte进行转换。
Life is not fair, get used to it.

Post Reply