Re: conversion from C string to unicode string

From: Asmus Freytag (asmusf@ix.netcom.com)
Date: Fri Jul 30 1999 - 16:58:52 EDT


>
>Dear people
>
>is there an easy way to convert a C string to a unicode string built
>into the microsoft Win 32 sdk e.g. some sort of library function??
>

Do you mean other than

MultiByteToWideChar (in the Win32API)
mbtowcs (in the C runtime)

The term multi byte is intended to cover all byte oriented encodings.
AFAIK, mbtowcs calls MultiByteToWideChar to get the work done on Win32.

>While I'm on the subject I don't suppose anyone would know does the
>Microsoft TAPI function LineOpen expect unicode as input for its
>dialable address. Thought not.

It's impossible to tell from their documentation, since the string
for the "displaybleAddress" (I assume that's what you meant) is given
by it's binary offset and length only, and not specified in a type safe
manner.

On an intel machine, often, passing English strings in Unicode to an API
that expects ASCII results in the truncation of the string after the first
characters. L"Hello World!" would come out as "H" since the 00 byte of the
L'H' is mistaken for the nul termination of "H". (Leading L is the standard
way to designate wide character string literals in C/C++).

So if you see this form of truncation that's a pretty good clue that you
are not supposed to have passed in Unicode. If you can pass in
"H\0e\0l\0l\0" with a length of 5 and it goes through then you can pass
L"Hello" instead.

>
>Any help would be much appreciated.
>
>Yours
>
>Neal Davies
>
>Ubiquity Software
>
>



This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:50 EDT