Page 1 of 1

Unicode Trouble - Getting a Text from an Editbox

Posted: Tue Apr 11, 2006 12:55 pm
by Das Gurke
Well, my problem is simpel. I have created an edit Box and want to read it out using the event handler.

The method "getText" returns a "const wchar_t *". And I have never really come across Unicode. So what exactly is wchar_t? Does it sort off replace the string variable? Or is it a kind of char replacement?

Or to put in in another way:

Code: Select all

const wchar_t * cXSize	= editFieldX->getText();
Does this store the whole Text of my Inputfield into cXSize?

Second problem: How would i convert a wchar_t to an integer / long? I dont quite get the hng out of wcstol. Or is there an easier function?

Posted: Tue Apr 11, 2006 1:00 pm
by sudi
do it like this
int i = atoi(stringc(editFieldX->getText()).c_str()); //converts to int
float i = atof(stringc(editFieldX->getText()).c_str()); //converts to float

Posted: Tue Apr 11, 2006 1:17 pm
by Das Gurke
Where do I take that stringc from?

Posted: Tue Apr 11, 2006 1:22 pm
by sudi
i don't know
maybe <string.h> or <stdio.h> or <conio.h> or <stdlib.h> or <cstdlib>
but i really don't remember

Posted: Tue Apr 11, 2006 1:25 pm
by Das Gurke
Not sure if we are talking apart.

stringc seemst so be a class or struct. So it should probably be initialized somewhere or am I mistaken? A quick google for "stringc c++ header" didn't quite bring satisfieng results :(

Posted: Wed Apr 12, 2006 10:13 am
by sudi
stringc is just a static function just like printf or scanf.......do u even have any clue about c++?

Posted: Wed Apr 12, 2006 10:33 am
by Das Gurke
Well, doesn't seem so ...

But:
Google can't tell me what stringc is, the MSDN doesn't have any kind of entry about stringc, cppreference.com doesn't know a function called stringc etc etc

And my compiler gives me the following error:

Code: Select all

\bomberman\IrrMainmenu.cpp(222) : error C2228: left of '.c_str' must have class/struct/union
.\bomberman\IrrMainmenu.cpp(222) : error C3861: 'stringc': identifier not found
I admit I dont really understand your way of parsing the edit box. I can only tell that a simple copy paste does not quite work ...

Edit: And i tried all your header proposals ...

Posted: Wed Apr 12, 2006 1:27 pm
by AndyCR
try:

#include <string>

...

(whatever is a char* that you want to convert the text to) = std::string(stringw(editFieldX->getText()).c_str()).c_str();

its ugly but it works.

Posted: Wed Apr 12, 2006 1:35 pm
by hybrid
Sudi wrote:stringc is just a static function just like printf or scanf.......do u even have any clue about c++?
Do you have :evil:
stringc is a Irrlicht-builtin class, better to be used as core::stringc. What you're proposing here is not some static function but a class constructor invocation. You're building an anonymous object which provides a c_str method to convert its contents to a char*. So care for your own business and learn c++ :!:
BTW: It's included in irrString.h

Posted: Wed Apr 12, 2006 4:19 pm
by sudi
:P
I already said i didn't know where it came from....

Posted: Wed Apr 12, 2006 4:27 pm
by hybrid
Yes, true. But you should try to say it without the attitude of the almighty when not being able to recognize the simplest C++ structure. If you don't know C++ you should not discredit others for it.

Posted: Wed Apr 12, 2006 7:26 pm
by sudi
Yeah yeah i know.....but i simply missed it......anyways lets stop this.

Posted: Thu Apr 13, 2006 9:56 am
by Midnight
You should never discredit anyone ever...

Unless you are a Dark Overlord such as myself (which you are not since I'm the only one assigned to this sector/dimension) OR

They are a gently caress-tard OR

You have signed written permission from a doctor.





or you're just an arse hole :roll: