Unicode Trouble - Getting a Text from an Editbox

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Das Gurke
Posts: 21
Joined: Sun Mar 05, 2006 7:39 pm

Unicode Trouble - Getting a Text from an Editbox

Post 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?
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Das Gurke
Posts: 21
Joined: Sun Mar 05, 2006 7:39 pm

Post by Das Gurke »

Where do I take that stringc from?
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post 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
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Das Gurke
Posts: 21
Joined: Sun Mar 05, 2006 7:39 pm

Post 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 :(
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

stringc is just a static function just like printf or scanf.......do u even have any clue about c++?
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Das Gurke
Posts: 21
Joined: Sun Mar 05, 2006 7:39 pm

Post 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 ...
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

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

Post 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
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

:P
I already said i didn't know where it came from....
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
hybrid

Post 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.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Yeah yeah i know.....but i simply missed it......anyways lets stop this.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post 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:
Post Reply