Unicode prob?
-
Hi all well i have a lil problem here I have created few classes and stuff and i have used normal char type variable. Now when i am writing code for UI, i have to use function strlen, strcpy , strcmp... For instance if i do...
char str[10]; CString Password; strcpy(str, Password);
In above code i get error saying can not convert parameter 2 from 'CString to const char*' So to overcome this problem i made these changes as shown below...wchar_t str[10]; CString Password; wcscpy(str, Password);
This solved my error but now i have many other errors. where i used char . So now do i have to change the whole application where i have used char. All the functions and stuff.. Is it now compulsory to use unicode in MFC....??? I am new to MFC so new to Unicode thingy..bit confusing though.. Can any one shed some light over this.. Any or all help would be greatly appreciated.. Thanks a lot -
Hi all well i have a lil problem here I have created few classes and stuff and i have used normal char type variable. Now when i am writing code for UI, i have to use function strlen, strcpy , strcmp... For instance if i do...
char str[10]; CString Password; strcpy(str, Password);
In above code i get error saying can not convert parameter 2 from 'CString to const char*' So to overcome this problem i made these changes as shown below...wchar_t str[10]; CString Password; wcscpy(str, Password);
This solved my error but now i have many other errors. where i used char . So now do i have to change the whole application where i have used char. All the functions and stuff.. Is it now compulsory to use unicode in MFC....??? I am new to MFC so new to Unicode thingy..bit confusing though.. Can any one shed some light over this.. Any or all help would be greatly appreciated.. Thanks a lotif you define _UNICODE you have to follow unicode. For CString to const char* error you could have used some macro for typecasting. no need to go for WCHAR. There are many other ways to e.g. password.GetBuffer(Password.GetLength()); which will return yoi char *.
-
Hi all well i have a lil problem here I have created few classes and stuff and i have used normal char type variable. Now when i am writing code for UI, i have to use function strlen, strcpy , strcmp... For instance if i do...
char str[10]; CString Password; strcpy(str, Password);
In above code i get error saying can not convert parameter 2 from 'CString to const char*' So to overcome this problem i made these changes as shown below...wchar_t str[10]; CString Password; wcscpy(str, Password);
This solved my error but now i have many other errors. where i used char . So now do i have to change the whole application where i have used char. All the functions and stuff.. Is it now compulsory to use unicode in MFC....??? I am new to MFC so new to Unicode thingy..bit confusing though.. Can any one shed some light over this.. Any or all help would be greatly appreciated.. Thanks a lotIt's not compulsory to use Unicode, you can remove the /D UNICODE from the MSVC project settings, but it is generally a good idea to go Unicode these days. The short answer to whether you are going to have to change all the code or not is YES and the sooner you do it the less painful it will be:(. One option is to change your
strcpy
s fortcscpy
s etc so that the code will compile with and without UNICODE defined. This way you can do the transition more gradually and in the meanwhile non Unicode builds which mix TCHARs with chars will work, keep putting in the changes to TCHAR functions until the code also builds and works in UNICODE. TCHAR and tcs functions turn into wchar and wcs with UNICODE defined(remeber to define _UINICODE as well beacuse someone at Microsoft screwed up) and they turn back into ordinary char stuff in non Unicode builds. You'll need <tchar.h> included of course. Welcome to the wonderful world of international software :-DNothing is exactly what it seems but everything with seems can be unpicked.
-
Hi all well i have a lil problem here I have created few classes and stuff and i have used normal char type variable. Now when i am writing code for UI, i have to use function strlen, strcpy , strcmp... For instance if i do...
char str[10]; CString Password; strcpy(str, Password);
In above code i get error saying can not convert parameter 2 from 'CString to const char*' So to overcome this problem i made these changes as shown below...wchar_t str[10]; CString Password; wcscpy(str, Password);
This solved my error but now i have many other errors. where i used char . So now do i have to change the whole application where i have used char. All the functions and stuff.. Is it now compulsory to use unicode in MFC....??? I am new to MFC so new to Unicode thingy..bit confusing though.. Can any one shed some light over this.. Any or all help would be greatly appreciated.. Thanks a lotHi, Always uses TCHAR instead of char / wchat_t and the generic-text functions defined in Tchar.h. This will maps appropriately if used _UNICODE or not.
-
if you define _UNICODE you have to follow unicode. For CString to const char* error you could have used some macro for typecasting. no need to go for WCHAR. There are many other ways to e.g. password.GetBuffer(Password.GetLength()); which will return yoi char *.
oh i wasn't aware of this.I already started changing stuff and error seems to be never ending. Hmm i got a backup of project though... So i guess i need to start it again. Well i have not define _UNICODE...and what could be solution you could think of in the problem i mentioned. Can we still use unicode without defining _UNICODE. I guess we can cos few things are working when i changed to wchar_t and i have not defined _UNICODE anywhere... Thanks