Hello eveyone!
A simple question again but it is still hard to me.Try to print a welcome msg to console,using both wxPuts and wxPrintf to print an unicode string,say Chinese characters just faied.Nothing printed:
wxWidget2.9.1 Unicode build under Windows XP:
#include <wx/wx.h>
void main()
{
wxPuts(wxT("欢迎来到中国!"));
wxPrintf(wxT("欢迎来到中国!"));
wxGetchar();
}
Could anybody figure me out what is the right way to print Chinese characters to console in wx?Thanks a lot.
Regards,
Sam
How to print Unicode(wchar) characters to console Topic is solved
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 am
Have you tried
this?
On linux, it works fine (Ubuntu -Jaunty, g++-4.4.0).
Sorry, i have no windows to try.
Regards
Orbitcowboy
Code: Select all
wxString msg(wxT("欢迎来到中国!"));
std::cout << msg.mb_str() << std::endl;
On linux, it works fine (Ubuntu -Jaunty, g++-4.4.0).
Sorry, i have no windows to try.
Regards
Orbitcowboy
[quote="orbitcowboy"]Have you tried
Thank you so much for your help.
The above code works.
But I am curious now isn't there such an equivalent method in wxWidgets?One has no other choice to do such task except importing std namespace?
Regards,
Sam
Code: Select all
wxString msg(wxT("欢迎来到中国!"));
std::cout << msg.mb_str() << std::endl;
The above code works.
But I am curious now isn't there such an equivalent method in wxWidgets?One has no other choice to do such task except importing std namespace?
Regards,
Sam
-
- I live to help wx-kind
- Posts: 178
- Joined: Mon Jul 23, 2007 9:01 am
I hope i understand you correctly... The msg.mb_str() is a wxWidgets function..samsam598 wrote:orbitcowboy wrote:Have you tried
Thank you so much for your help.Code: Select all
wxString msg(wxT("欢迎来到中国!")); std::cout << msg.mb_str() << std::endl;
The above code works.
But I am curious now isn't there such an equivalent method in wxWidgets?One has no other choice to do such task except importing std namespace?
Regards,
Sam
I recommend to read this wiki page, it helped me a lot.
http://wiki.wxwidgets.org/WxString
Best regards
Orbitcowboy
-
- Super wx Problem Solver
- Posts: 323
- Joined: Sun Jun 08, 2008 11:59 am
- Location: Bordeaux, France
No it isn't. The only way is to use cout from the c++ standard library.samsam598 wrote:
But I am curious now isn't there such an equivalent method in wxWidgets?One has no other choice to do such task except importing std namespace?
Regards,
Sam
But it is c++ integrated, and you can use it from everywhere by using std:: so I don't know where is the problem.
OS: Ubuntu 11.10
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3
[/quote]
No it isn't. The only way is to use cout from the c++ standard library.
But it is c++ integrated, and you can use it from everywhere by using std:: so I don't know where is the problem.[/quote]
I do know no problem using std in general.I rememberd in the wx Doc or somewhere I read that import stl should be avoided since it will largely delay the compiling time and increase the code size(Please correct me if I am completely wrong),this is why I have such a question.I mixed stl and std in mind at that moment.Sorry for such a mess!
Best Regards,
Sam
No it isn't. The only way is to use cout from the c++ standard library.
But it is c++ integrated, and you can use it from everywhere by using std:: so I don't know where is the problem.[/quote]
I do know no problem using std in general.I rememberd in the wx Doc or somewhere I read that import stl should be avoided since it will largely delay the compiling time and increase the code size(Please correct me if I am completely wrong),this is why I have such a question.I mixed stl and std in mind at that moment.Sorry for such a mess!
Best Regards,
Sam