Author Topic: Last standing unicode problem  (Read 21516 times)

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Last standing unicode problem
« on: November 24, 2005, 02:02:40 pm »
Bold title for a topic :)

Well, I 've updated my local wx installation to wx2.6.2/unicode and fixed all minor incompatibilities.
Except for one thing:

Code
int someint;
wxString astr;
wxString anotherstr;

astr << _T("aval"); // ok
astr << anotherstr; // ok
astr << someint; // *not* ok

I can't stream numbers to wxString  :shock:
Anyone else has seen this? Knows a workaround?
The only workaround I found is using wxString::Format() instead of streams but this would mean scanning the entire source tree to find where integers are streamed to wxString and alter the code...
Be patient!
This bug will be fixed soon...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Last standing unicode problem
« Reply #1 on: November 24, 2005, 06:36:08 pm »
a little bit offtopic, but if you already moved to wx262, what happened to the splitpanel position problem? (the splitter position getting forgotten). Is that fixed already?

takeshimiya

  • Guest
Re: Last standing unicode problem
« Reply #2 on: November 24, 2005, 06:52:57 pm »
What happens if you change these defaults?:

// If enabled (1), compiles wxWidgets streams classes
#define wxUSE_STREAMS       1

// Use standard C++ streams if 1. If 0, use wxWin streams implementation only.
#define wxUSE_STD_IOSTREAM  0

// Enable conversion to standard C++ string if 1.
#define wxUSE_STD_STRING  0


The wxWidgets stream classes may have bugs.
« Last Edit: November 24, 2005, 06:58:02 pm by Takeshi Miya »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Last standing unicode problem
« Reply #3 on: November 24, 2005, 07:49:11 pm »
a little bit offtopic, but if you already moved to wx262, what happened to the splitpanel position problem? (the splitter position getting forgotten). Is that fixed already?

I 've fixed it for the classbrowser since lastweek.
I 'll fix it for open files list too.

What happens if you change these defaults?:

// If enabled (1), compiles wxWidgets streams classes
#define wxUSE_STREAMS 1

// Use standard C++ streams if 1. If 0, use wxWin streams implementation only.
#define wxUSE_STD_IOSTREAM 0

// Enable conversion to standard C++ string if 1.
#define wxUSE_STD_STRING 0


The wxWidgets stream classes may have bugs.

Thanks for the suggestion, but I would like not to tamper with wx settings.
First, because it 'd make the build process more difficult for new users.
Second, because most linux users will use the pre-built wx lib coming with their distro. We should not force them to build wx themselves, not to mention that C::B would never stand a chance to become a part of distros then...

Well, seems like I 'll have to dig through the code and replace those instances with wxString::Format()...
Be patient!
This bug will be fixed soon...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Last standing unicode problem
« Reply #4 on: November 24, 2005, 08:46:45 pm »
wxString::operator <<

wxString& operator <<(int i)
wxString& operator <<(float f)
wxString& operator <<(double d)

These functions work as C++ stream insertion operators: they insert the given value into the string. Precision or format cannot be set using them, you can use Printf for this.

--

Yiannis, mind explaining exactly why you can't use it? It throws a runtime error or what?

takeshimiya

  • Guest
Re: Last standing unicode problem
« Reply #5 on: November 24, 2005, 08:49:58 pm »
Errm, I suggest those settings only to test if it's a wxWidgets bug in the stream classes.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Last standing unicode problem
« Reply #6 on: November 24, 2005, 09:07:04 pm »
Yiannis, mind explaining exactly why you can't use it? It throws a runtime error or what?

Nope, just it isn't actually added to the string:

Code
wxString astr = "Test";
astr << 5;

astr == "Test", instead of "Test5"...
Be patient!
This bug will be fixed soon...

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Last standing unicode problem
« Reply #7 on: November 24, 2005, 11:33:09 pm »
how about using the stl streams directly, should be portable ;
ostringstream class (things go into a sting buffer which can be requested at the end of all appending); ostringstream is just like cout, only everything get's into a strring.

But then again, you have to replace stuff, which you wanted to prevent doing in the first place ;-)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Last standing unicode problem
« Reply #8 on: November 24, 2005, 11:53:36 pm »
Yiannis: Mind giving us a particular filename / line no. ?

takeshimiya

  • Guest
Re: Last standing unicode problem
« Reply #9 on: November 25, 2005, 12:15:52 am »
killerbot: that's why I'm saying to test with the STL streams instead of the wx streams. Only to know if it's a bug of wx or not.
#define wxUSE_STD_IOSTREAM  1
#define wxUSE_STD_STRING  1
« Last Edit: November 25, 2005, 12:17:25 am by Takeshi Miya »

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Last standing unicode problem
« Reply #10 on: November 25, 2005, 12:32:29 am »
Yiannis: Mind giving us a particular filename / line no. ?

Sure. Here's the file I noticed the problem:

file: src/plugins/debuggergdb/gdb_commands.h
line: 189

Code
m_Cmd << out << _T(":") << bp->line + 1;
Be patient!
This bug will be fixed soon...

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Last standing unicode problem
« Reply #11 on: November 25, 2005, 12:40:30 am »
Quote
m_Cmd << out << _T(":") << bp->line + 1;

Try this:

Code
m_Cmd << out << _T(":") << (bp->line + 1);

Or this:


Code
m_Cmd << out << _T(":");
m_Cmd << (bp->line + 1);

Or this:

Code
(m_Cmd << out << _T(":")) << (bp->line + 1);

And tell us what happens.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Last standing unicode problem
« Reply #12 on: November 25, 2005, 10:02:51 am »
Be patient!
This bug will be fixed soon...

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Last standing unicode problem
« Reply #13 on: December 02, 2005, 12:19:16 pm »
Just curious, but does this work-around work?:
Code
std::string str;
str << "Hi" << 5;
wxString str_new(_T(str));

Please notice that I've used default std::string for the first one.
(I cannot test it at the moment since I am at work.)

Morten.
« Last Edit: December 02, 2005, 12:22:15 pm by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Last standing unicode problem
« Reply #14 on: December 02, 2005, 12:56:25 pm »
Just curious, but does this work-around work?:
Code
std::string str;
str << "Hi" << 5;
wxString str_new(_T(str));

Please notice that I've used default std::string for the first one.
(I cannot test it at the moment since I am at work.)

Morten.


Using the STL is not an accepted solution...
Be patient!
This bug will be fixed soon...