Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Easy way to convert char string to wchar_t string?

0 views
Skip to first unread message

Adriaan Tijsseling

unread,
Dec 4, 2000, 3:00:00 AM12/4/00
to
See Subject line. Any suggestions very appreciated :)

Adriaan

David Phillip Oster

unread,
Dec 4, 2000, 3:00:00 AM12/4/00
to
In article <adriaan-20DFDC...@news-newark.rutgers.edu>,
Adriaan Tijsseling <adr...@pavlov.rutgers.edu> wrote:

> See Subject line. Any suggestions very appreciated :)

// strcopyToWide - assumes large enough. casts are so high byte is 0.
void strcopyToWide(wchar_t * dest, char *src){
while('\0' != *src){ *dest++ = (wchar_t ) (unsigned char) *src++; }
*dest++ = *src++;
}

As stated, your question is meaningless. What character sets are the
source strings in, and what character set is the dest string in?

The algorithm for converting between a char* holding macintosh
WorldscriptII Japanese going to 16-bit per char Unicode is very
different from the algorithm for going from a char * of UTF-8 to
Unicode, for example.

You might like to look at the documentation for two of Apple's mavinitsh
"Managers":

http://developer.apple.com/techpubs/macos8/TextIntlSvcs/ATSUI/atsui.html
ATSUI - Apple Text Services for Unicode Imaging (ATSUI is a pun in
Japanese) and
Text Encoding Conversion Manager.
http://developer.apple.com/techpubs/macos8/TextIntlSvcs/TextEncodingConve
rsionManager/tecmgr.html

MW Ron

unread,
Dec 4, 2000, 3:00:00 AM12/4/00
to

> See Subject line. Any suggestions very appreciated :)
>

> Adriaan

Won't swprintf work?

#include <wchar.h>

int main()
{
wchar_t wstr[100];
char buffer [100]= "able was I ere I saw elba";
swprintf(wstr, 100, L"%ls",buffer);

wprintf(L"%s", wstr);
}

--
Create Java applications from desktop to wireless devices
using Sun's J2SE(tm), PersonalJava(tm) and J2ME(tm)
http://www.metrowerks.com/java/

Metrowerks "Software Starts Here" MW...@metrowerks.com

0 new messages