|
For Example i took char[100] As you mentioned i need to take the length of the string.
Thankyou Albert.
|
|
|
|
|
Use strcpy() or its wide character equivalent for the copy. For further information see here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Forgot you can use that on a CString... 
|
|
|
|
|
If I had $1 for everything I've forgotten ...
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
LPSTR WideChar2MBCS( const CString& strCS )
{
const UINT wLen = strCS.GetLength() + 1;
UINT aLen = WideCharToMultiByte(CP_ACP,0,strCS,wLen,NULL,0,NULL,NULL);
LPSTR lpa = new char[aLen];
WideCharToMultiByte(CP_ACP,0,strCS,wLen,lpa,aLen,NULL,NULL);
return lpa;
}
maybe this will help you.
myblog is: http://www.cppblog.com/stonexin/archive/2011/12/01/161280.html
|
|
|
|
|
btw,this is unicode project.
|
|
|
|
|
|
CString str = _T( "Test string." );
char pBuffer[ 100 ];
if( sizeof( TCHAR ) == 2 )
WideCharToMultiByte( CP_ACP, 0, ( WCHAR* )str.GetBuffer(), -1, pBuffer, 100, NULL, NULL );
else
{
char* pTemp = ( char* )str.GetBuffer();
memcpy_s( pBuffer, 100, pTemp, strlen( pTemp ) + 1 );
}
|
|
|
|
|
I have a dll COM , I want to convert it to UNICODE.
I readed some documentations about this but I can't get what I should do to be sure that the conversion is done correctly or Not
these are some remarks i have done in my code :
- Use of CString
- char changed by _TCHAR
- char*, LPSTR (Win32 data type) changed by LPTSTR
- const char*, LPCSTR (Win32 data type) changed by LPCTSTR
- USES_CONVERSION macro
- use of std::wstring instead of std::string
- change characters set of project to UNICODE
I don't know if it is sufficient or there are others things to do
And How can I check after conversion if it is Ok or Not.
Thanks for reply.
|
|
|
|
|
You also need to make sure all your string literals ar changed from char to TCHAR with the _T() macro like this:
const char* cp = "Ansi string"; PCTSTR tcp = _T("TCHAR string");
After that, the only way to be certain you have it right is to desk check and test. There may be some free tools around to help verify it but I'm not aware of them; Google may help you.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
If that was you who downvoted my answer, I'd be interested to know why.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
sorry for that, I thought to click on 5, not to worry
Just question please :
If I change the Option "Character Set" to "Use Unicode Character Set" and compile
If there is no error can we say that the version compiled without error is UNICODE now or not ?
|
|
|
|
|
khaliloenit wrote: If there is no error can we say that the version compiled without error is UNICODE now or not ?
Unfortunately no. The compiler should weed out most of the anomalies as it will reject a char where a WCHAR is required, but you still need to do all the things you mentioned in your original message and check the things I suggested. Your project is now probably Unicode but you must still check that you have not missed anything, and test it thoroughly. For example if you have something like:
char* charP = "Hello, World";
that is perfectly legal code in a Unicode program but it may not be what you want.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
What about :
unsigned char
unsigned char*
unsigned char const*
char **
in UNICODE ? By what we can replace them ?
|
|
|
|
|
You would normally replace all of them by WCHAR (TCHAR defaults to WCHAR in a Unicode compilation). However, you first need to look at the context to see what the variables are being used for.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
See an other problem please :
I have this table of char (NO UNICODE):
const char sm_S[8] = {9, 124, 119, 123, -14, 107, 111, -59};
and I want to work with it now on UNICODE : I convert it to
const TCHAR sm_S[8] = {9, 124, 119, 123, -14, 107, 111, -59};
But when I do like this :
TCHAR MyChar = sm_S[4]; this should be "-14" but I have an other value like "54265"
What do you think about this and have you idea to solve this problem?
|
|
|
|
|
Firstly, stop using decimal numbers in your constants, use proper character constants. Secondly, as explained before Unicode is 16 bit unsigned so the value you see is quite correct.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thnk you for repley.
About the first point : can you give me a link to table which contains the caracters with their numbers in decimal to change all them.?
Second : if this is correct have you idea to correct it ?
|
|
|
|
|
khaliloenit wrote: can you give me a link to table which contains the caracters with their numbers in decimal
Use Character Map in Windows.
khaliloenit wrote: if this is correct have you idea to correct it ?
Sorry I don't understand what you are asking.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Dear all,
My current project was built on visual studio 2005. I ported it into visual studio 2010 and after several configurations, I got the only one left error while building
stdafx.obj : error LNK2019: unresolved external symbol _WTSSendMessageA@40 referenced in function _SendNotification
9>nafxcw.lib(afxglobals.obj) : error LNK2001: unresolved external symbol _IID_IWICImagingFactory
9>nafxcw.lib(afxtaskspane.obj) : error LNK2001: unresolved external symbol __imp__ImageList_GetIconSize@12
9>nafxcw.lib(afxvisualmanager.obj) : error LNK2019: unresolved external symbol __imp__ImageList_GetIconSize@12 referenced in function "public: virtual void __thiscall CMFCVisualManager::OnDrawTask(class CDC *,class CMFCTasksPaneTask *,class CImageList *,int,int)" (?OnDrawTask@CMFCVisualManager@@UAEXPAVCDC@@PAVCMFCTasksPaneTask@@PAVCImageList@@HH@Z)
9>nafxcw.lib(afxvisualmanagerofficexp.obj) : error LNK2001: unresolved external symbol __imp__ImageList_GetIconSize@12
9>nafxcw.lib(afxstatusbar.obj) : error LNK2001: unresolved external symbol __imp__ImageList_GetIconSize@12
9>nafxcw.lib(afxheaderctrl.obj) : error LNK2001: unresolved external symbol __imp__ImageList_GetIconSize@12
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_ReplaceIcon@12 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneAnimation(int,struct _IMAGELIST *,unsigned int,int)" (?SetPaneAnimation@CMFCStatusBar@@QAEXHPAU_IMAGELIST@@IH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_GetIcon@12 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneAnimation(int,struct _IMAGELIST *,unsigned int,int)" (?SetPaneAnimation@CMFCStatusBar@@QAEXHPAU_IMAGELIST@@IH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_Create@20 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneAnimation(int,struct _IMAGELIST *,unsigned int,int)" (?SetPaneAnimation@CMFCStatusBar@@QAEXHPAU_IMAGELIST@@IH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_GetImageCount@4 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneAnimation(int,struct _IMAGELIST *,unsigned int,int)" (?SetPaneAnimation@CMFCStatusBar@@QAEXHPAU_IMAGELIST@@IH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_Destroy@4 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneAnimation(int,struct _IMAGELIST *,unsigned int,int)" (?SetPaneAnimation@CMFCStatusBar@@QAEXHPAU_IMAGELIST@@IH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_AddMasked@12 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneIcon(int,struct HBITMAP__ *,unsigned long,int)" (?SetPaneIcon@CMFCStatusBar@@QAEXHPAUHBITMAP__@@KH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_Remove@8 referenced in function "public: void __thiscall CMFCStatusBar::SetPaneIcon(int,struct HBITMAP__ *,unsigned long,int)" (?SetPaneIcon@CMFCStatusBar@@QAEXHPAUHBITMAP__@@KH@Z)
9>nafxcw.lib(afxstatusbar.obj) : error LNK2019: unresolved external symbol __imp__ImageList_DrawEx@40 referenced in function "protected: virtual void __thiscall CMFCStatusBar::OnDrawPane(class CDC *,class CMFCStatusBarPaneInfo *)" (?OnDrawPane@CMFCStatusBar@@MAEXPAVCDC@@PAVCMFCStatusBarPaneInfo@@@Z)
Do you have any suggestion to fix the bug ?
|
|
|
|
|
Check that all the required libraries are included in your project's Linker properties, and also that their directories are included in the VC++ Directories property.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
definitely !! after spending some hours googling, finally i figured out which lib i missed. Thank you very much 
|
|
|
|
|
Hello,
Others are likely to encounter the same problem as you did. Providing the solution in addition to saying that you found it might be helpful to others (like me). It is always anoying find out someone had the exact same problem and says he solved it, but won't say how he did.
Can you tell me what lib you were missing ?
Redgis
|
|
|
|
|
A quick Google of the missing symbols gives the following missing library linkages:
WTSSendMessage Wtsapi32.lib
ImageList_GetIconSize Comctl32.lib
IWICImagingFactory Windowscodecs.lib
All of the other ImageList* missing symbols are found in Comctl32.
|
|
|
|
|