Accented chars problem

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
fortikur
Posts: 25
Joined: Tue Nov 15, 2005 3:59 pm
Location: Hungary

Accented chars problem

Post by fortikur »

I want to print accented characters (like éáőü) on a button. I know, I have to use a wchar_t. This is how I tried to do it:

main.cpp

Code: Select all

 char szov[20];
 FILE *fh;
 fh=_wfopen(L"res\\textx.txt",L"r");
 fscanf(fh,"%s",&szov);
 fclose(fh);   

env->addButton(rect<s32>(10,210,120,230), 0, 101, wide(szov)); 

In a .h file:

Code: Select all

wchar_t* wide(char *a){
int p;
for(p=0;p<strlen(a);p++){
   buf[p]=a[p];
                            }
   buf[p]='\0';
return buf;
}
I know this code could be optimised to death, but now I'm only concerned about its working.
I tried with the wsprintf thing, but Gcc showed me an error...

If I write:
env->addButton(rect<s32>(10,210,120,230), 0, 101, L"éáőúü");
it works fine, but there is something wrong with my function that returns the string.
What am I missing here?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you copy a char* to wchar_t* you'll never get the correct chars. you have to use mbstowcs() for it.
fortikur
Posts: 25
Joined: Tue Nov 15, 2005 3:59 pm
Location: Hungary

Post by fortikur »

Thank you. I will try it.
I hope this will solve the problem :)
Post Reply