OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:47 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Unicode
PostPosted: Wed Jan 22, 2003 9:52 pm 
Hi,

Just wondering if anyone can tell me where I can find an in depth article on using unicode in c++ apps.

I want to make it completely unicode compatible, also I need to know what unicode c functions to substitute for the standard ansi string functions (string.h).

If it is not that difficult then could some just tell me here.

I know that strings should be placed inside the _T() macro, and I am supposed to use TCHAR instead of char but what includes do I use and what c functions do I use to manage the strings.

thanks.


Top
  
 
 Post subject: Re:Unicode
PostPosted: Thu Jan 23, 2003 4:39 pm 
if you've got TCHAR's, then include tchar.h and use those string manipulation functions.

they generally follow this naming rule...if the function starts with str when you use the regular char data type, then the TCHAR equivalent will start with _tcs instead, so:

_tcscpy equates to strcpy
_tcsncpy equates to strncpy
_tcscat equates to strcat

and so on

The names of all the TCHAR equivalents for string functions can be seen if you look at tchar.h.

You can see that toupper translates to totupper, and so on.

Also, I think it may be better to get in the habit of using the TEXT macro instead of _T, because I think _T is only defined when you're using MFC, whereas TEXT is defined when using regular old windows.h and when using MFC.


Top
  
 
 Post subject: Re:Unicode
PostPosted: Thu Jan 23, 2003 4:42 pm 
incidentally, if you are using MFC, then the CString class uses TCHAR as its base type, so it is already Unicode compatible.


Top
  
 
 Post subject: Re:Unicode
PostPosted: Thu Jan 23, 2003 7:04 pm 
Another good trick is:
Code:
#include <tchar.h>
#include <string>

typedef std::basic_string<TCHAR> tstring;

This gives you a Unicode/ANSI std::string class.


Top
  
 
 Post subject: Re:Unicode
PostPosted: Thu Jan 23, 2003 9:11 pm 
Ok, thanks for your help. :D


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group