Wine Developer Cheatsheet, v1

Vincent Béron vberon at mecano.gme.usherb.ca
Mon Sep 6 13:23:17 CDT 2004


Le lun 06/09/2004 à 14:04, Rolf Kalbermatter a écrit :
> "Diego 'Flameeyes' =?ISO-8859-1?Q?Petten=F2?=" wrote:
> 
> >I have only a doubt:
> >
> >> - Is it possible to implement the ANSI version by converting to unicode
> >>    then calling the wide version, rather than duplicate it?
> >
> >How can I convert an ansi string to a unicode one and reverse? So I can redo
> >the patch with the calls :)
> 
> Typically you use MultiByteToWideChar() for any input strings and then
> WideCharToMultiByte() for possible output strings. You can look at
> shlwapi/path.c and other files in there to see how this is usually done.
> 
> Depending on the place where you do it, it might be preferable to use
> dynamically allocated buffers instead of using stack space as Wine is
> already using quite a lot of stack. Principle:
> 
>     WCHAR *textW;
>     INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
>     if((textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
>     {
>         MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
> 
>         /* Do the Widechar call */
>   
>         HeapFree(GetProcessHeap(), 0, textW);
>     }

Is it best to use MultiByteToWideChar() or
RtlCreateUnicodeStringFromAsciiz()? I find that latter function much
easier to use (no need to mess with string lengths, etc.).

Vincent





More information about the wine-devel mailing list