News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Last standing unicode problem

Started by mandrav, November 24, 2005, 02:02:40 PM

Previous topic - Next topic

mandrav

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:


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...

rickg22

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

#2
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.

mandrav

Quote from: rickg22 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?

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

Quote from: Takeshi Miya 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.

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...

rickg22

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

Errm, I suggest those settings only to test if it's a wxWidgets bug in the stream classes.

mandrav

Quote from: rickg22 on November 24, 2005, 08:46:45 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:


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

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

killerbot

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 ;-)

rickg22

Yiannis: Mind giving us a particular filename / line no. ?

takeshimiya

#9
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

mandrav

Quote from: rickg22 on November 24, 2005, 11:53:36 PM
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

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

rickg22

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

Try this:


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


Or this:



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


Or this:


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


And tell us what happens.

mandrav

Be patient!
This bug will be fixed soon...

MortenMacFly

#13
Just curious, but does this work-around work?:

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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

mandrav

Quote from: MortenMacFly on December 02, 2005, 12:19:16 PM
Just curious, but does this work-around work?:

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...