0
0

Hi,

I’ve queryed a tag by using the getTag-Method. The datatype of this Tag is FMOD_TAGDATATYPE_STRING_UTF8. How can i convert the String to a ANSI-String ?

I’ve already tried this, but it doesn’t work:
[code:1688xrlf]
// pvSrc was previously initialized with the correct pointer determined by getTag (Element: void * data).
wchar_t* pszSrc = reinterpret_cast<wchar_t>(pvSrc);
unsigned int uiStrLen = lstrlenW(pszSrc) + 1;
char
pszDest = new char[uiStrLen];
WideCharToMultiByte(CP_UTF8, 0L, pszSrc, uiStrLen, pszDest, uiStrLen, NULL, NULL);
MessageBoxA(NULL, pszDest, NULL, 0);
delete [] pszDest;
[/code:1688xrlf]
(The destination-bufffer (‘pszDest’) just contains some question-marks (?), after the operation)

Thx in advance!

  • You must to post comments
0
0

so, it looks like you need to go from wide chars to multibyte chars? if thats the case, you can use wcstombs:

[code:1thhngd8]
wchar_t* wcharBuffer = (wchar_t)malloc(bufferSize);
char
charBuffer = (char*)malloc(bufferSize);

// copy something into wcharBuffer

wcstombs(charBuffer, wcharBuffer, bufferSize);

// do whatever with charBuffer here

free(wcharBuffer);
free(charBuffer);

[/code:1thhngd8]

the wide versions of strcpy and strcat are wcscpy and wcscat. also, if you need to assign a wchar_t *, you can just use L:

[code:1thhngd8]
wchar_t* string = L"Some string";
[/code:1thhngd8]

hope this helps

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.