Jump to content
Nytro

[C] UnicodeToString - StringToUnicode

Recommended Posts

Posted

[C] UnicodeToString - StringToUnicode

Author: Xash

#include <windows.h>

void UnicodeToString(const wchar_t* pStringW, char* pStringA, const int stringLength)
{
int i = 0;

while(i < stringLength)
{
*(pStringA + i) = (char)(BYTE)*(pStringW + i);
i++;
}

*(pStringA + i) = (char)0x00;
}

void StringToUnicode(const char* pStringA, wchar_t* pStringW, const int stringLength)
{
int i = 0;

while(i < stringLength)
{
*(pStringW + i) = (wchar_t)(BYTE)*(pStringA + i);
i++;
}

*(pStringW + i) = (wchar_t)0x00;
}

int main()
{
wchar_t testStringW[20] = L"I'm a test!";
char testStringA[20] = {""};

UnicodeToString(testStringW, testStringA, lstrlenW(testStringW));
MessageBoxA(0, testStringA, "Hello", MB_OK);

return 0;
}

Sursa: UnicodeToString - StringToUnicode

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...