   Unicode string trouble
  Hi there, sorry for my newbie question, but i always programmed when unicode was not used, and now i'm getting some troubles to do some simple operations.I simply would like to make an operation like this (i write the code in the old style):I use Visual Studio 2008 C++ Lang,here is the concept...what i want to do is to pass a string value to a function and this function copies this string in another string variable.char *s1;char *s2;sprintf (s1, "%s", s2);or something like strcpy even if i prefer sprintf.With unicode active i don't find a solution.Can you illuminate me.thx[Edited by - Aju on May 7, 2010 2:56:47 PM]
  You can use the wide char version from the <wchar.h> header file that comes with the visual studio install.  The function names are a little different, but there is a wide char version for every char function like sprintf and strcpy.You can also write your code to compile to either char or wchar_t using the <tchar.h> header file.  Here the existence or non existance of the _UNICODE #define will choose which type is used in your code.  There are TCHAR version of all string functions too.For instance some of the mappings are:charstrcpywchar_t  wcscpyTCHAR    _tcscpyOr char    sprintfwchar_t swprintfTCHAR   _stprintfSo your code could be:// uncomment this to enable unicode// #define _UNICODE #include <windows.h>#include <tchar.h>TCHAR* pStr = _T("my string data");TCHAR pStrAr[64];_tcscpy( pStrAr, 64, pStr );#include <windows.h>#include <wchar.h>wchar_t* pStr = L"my string data";wchar_t pStrAr[64];wcscpy( pStrAr, 64, pStr );To get real unicode encoding like UTF8 or UTF16 you'll have to do some stuff with the programs local information which I don't know very well.You can also read a unicode string into an asci array using the %S instead of %s in a sprintf call.   ;  If you're using C++, you should be using (at a very minimum) std::string and std::wstring.   ;  You mention C++, but are using c-strings.Why not use std::wstring/std::string. Then you can have fun while being safe :).Note that for any real unicode usage (as in actual UNICODE work, not just moving/printing unicode strings), you'll have to dig into the win32 SDK and pull out the string manipulation functions there (as in finding out how many "characters" (not code points) are in a string).   ;Quote:Original post by AjuI use Visual Studio 2008 C++ Lang,std::wstring