This site is no longer active and is available for archival purposes only. Registration and login is disabled.

LPSTR to LPWSTR ?


LPSTR to LPWSTR ?

Postby Swann » Feb 6, 2004 @ 12:40pm

Swann
pm Member
 
Posts: 4
Joined: Jan 14, 2004 @ 10:08am


Postby kornalius » Feb 6, 2004 @ 12:50pm

User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby superman » Feb 7, 2004 @ 5:41pm

"Kittens give Morbo gas." - Morbo the News Monster
User avatar
superman
pm Member
 
Posts: 99
Joined: Nov 3, 2001 @ 1:09am


Postby Dan East » Feb 7, 2004 @ 6:55pm

Well, this doesn't really need to be a separate function either. The w[strlen(s)]=0; is not necessary:

cbMultiByte
If this parameter is -1, the function processes the entire input string including the null terminator. The resulting wide character string therefore has a null terminator, and the returned length includes the null terminator.

If you've got a static buffer you're translating the string into then you can just do a simple call:

TCHAR szOut[1024];
WideCharToMultiByte(CP_ACP, 0, s, -1, szOut, sizeof(szOut)/sizeof(TCHAR));

_stprintf is the TCHAR version of sprintf.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron