Click here to Skip to main content
15,938,682 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Call Managed Code (c#) from unmanaged code (vc++ 6.0) Pin
playxn14-Oct-08 4:58
playxn14-Oct-08 4:58 
GeneralRe: Call Managed Code (c#) from unmanaged code (vc++ 6.0) Pin
Matthew Faithfull14-Oct-08 5:31
Matthew Faithfull14-Oct-08 5:31 
GeneralRe: Call Managed Code (c#) from unmanaged code (vc++ 6.0) Pin
playxn15-Oct-08 5:02
playxn15-Oct-08 5:02 
GeneralRe: Call Managed Code (c#) from unmanaged code (vc++ 6.0) Pin
Matthew Faithfull15-Oct-08 6:38
Matthew Faithfull15-Oct-08 6:38 
QuestionUTF8 Encoding problem Pin
Dhiraj kumar Saini14-Oct-08 2:49
Dhiraj kumar Saini14-Oct-08 2:49 
AnswerRe: UTF8 Encoding problem Pin
Mark Salsbery14-Oct-08 3:41
Mark Salsbery14-Oct-08 3:41 
GeneralRe: UTF8 Encoding problem Pin
Dhiraj kumar Saini14-Oct-08 22:43
Dhiraj kumar Saini14-Oct-08 22:43 
GeneralRe: UTF8 Encoding problem Pin
Mark Salsbery15-Oct-08 5:41
Mark Salsbery15-Oct-08 5:41 
What is the type of characters passed to your EncodeToUTF8 method?
You use LPCTSTR as the passed parameter type, which can be a
const char * or a const wchar_t * ... which is it?

If you are going to do specific character set conversions, you need
to use specific char types, not generics.

Here's an example of your EncodeToUTF8() method for a Unicode build
<code>CStringA</code> CChatManager::EncodeToUTF8(LPCTSTR szSource)
{
	CStringA utf8str;

#ifdef _UNICODE
	int utf8length = ::WideCharToMultiByte(CP_UTF8, 0, szSource, -1, NULL, 0, NULL, NULL);
	if (utf8length > 0)
	{
		char *utf8strchars = utf8str.GetBuffer(utf8length - 1);
		::WideCharToMultiByte(CP_UTF8, 0, szSource, -1, utf8strchars, utf8length, NULL, NULL);
		utf8str.ReleaseBuffer();
	}
#endif

	return utf8str;
}

Note I changed the return type to a more specific CStringT type that
is the most appropriate for UTF-8.

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

Questioncan one switch off the implicit inline rule? Pin
WernerP14-Oct-08 2:16
WernerP14-Oct-08 2:16 
AnswerRe: can one switch off the implicit inline rule? Pin
Rajesh R Subramanian14-Oct-08 3:05
professionalRajesh R Subramanian14-Oct-08 3:05 
QuestionRe: can one switch off the implicit inline rule? Pin
David Crow14-Oct-08 3:05
David Crow14-Oct-08 3:05 
AnswerRe: can one switch off the implicit inline rule? Pin
Roger Stoltz14-Oct-08 3:11
Roger Stoltz14-Oct-08 3:11 
GeneralRe: can one switch off the implicit inline rule? Pin
WernerP14-Oct-08 3:47
WernerP14-Oct-08 3:47 
GeneralRe: can one switch off the implicit inline rule? Pin
Roger Stoltz14-Oct-08 4:10
Roger Stoltz14-Oct-08 4:10 
GeneralRe: can one switch off the implicit inline rule? Pin
WernerP14-Oct-08 4:53
WernerP14-Oct-08 4:53 
AnswerRe: can one switch off the implicit inline rule? Pin
Roger Stoltz14-Oct-08 4:59
Roger Stoltz14-Oct-08 4:59 
GeneralRe: can one switch off the implicit inline rule? Pin
WernerP14-Oct-08 5:14
WernerP14-Oct-08 5:14 
GeneralRe: can one switch off the implicit inline rule? [modified] Pin
Rajesh R Subramanian14-Oct-08 5:16
professionalRajesh R Subramanian14-Oct-08 5:16 
GeneralRe: can one switch off the implicit inline rule? Pin
WernerP14-Oct-08 6:02
WernerP14-Oct-08 6:02 
GeneralRe: can one switch off the implicit inline rule? Pin
Rajesh R Subramanian14-Oct-08 21:01
professionalRajesh R Subramanian14-Oct-08 21:01 
AnswerRe: can one switch off the implicit inline rule? Pin
toxcct14-Oct-08 3:35
toxcct14-Oct-08 3:35 
GeneralRe: can one switch off the implicit inline rule? Pin
CPallini14-Oct-08 3:39
mveCPallini14-Oct-08 3:39 
GeneralRe: can one switch off the implicit inline rule? Pin
WernerP14-Oct-08 4:05
WernerP14-Oct-08 4:05 
GeneralRe: can one switch off the implicit inline rule? Pin
David Crow14-Oct-08 4:23
David Crow14-Oct-08 4:23 
GeneralRe: can one switch off the implicit inline rule? Pin
Roger Stoltz14-Oct-08 4:35
Roger Stoltz14-Oct-08 4:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.