[clean-list] nCopyAnsiToWideChar

Serguey Zefirov thesz@mail.ru
Sat, 8 Jun 2002 00:36:13 +0400


Hello clean-list,

I'd like to suggest the following version of nCopyAnsiToWideChar
function in the file $clean20root/Libraries/ObjectIO 1.2.2/OS
Windows/Windows_C_12/util_121.c:
------------------------------------------------------------------------------
int nCopyAnsiToWideChar (LPWORD lpWCStr, LPSTR lpAnsiIn)
{
        int nChar = MultiByteToWideChar(
                CP_ACP,         /* default ANSI Code page */
                0,              /* no special flags */
                lpAnsiIn,       /* multibyte char */
                -1,     /* ASCIIZ */
                lpWCStr,        /* wide characters (dummy right now) */
                0               /* flag that we need to calculate
                                   string length */
        );
        nChar = MultiByteToWideChar(
                CP_ACP,         /* default ANSI Code page */
                0,              /* no special flags */
                lpAnsiIn,       /* multibyte char */
                -1,     /* ASCIIZ */
                lpWCStr,        /* destination wide character string */
                nChar   /* calculated number of wide chars */
        );
        if (nChar==0) {    /* failure result */
                MessageBox (0,"nCopyAnsiToWideChar fails","MultiByteToWideChar",0);
                ExitProcess(255);       /* this is plain wrong but this is windows after all */
        }

        return nChar;            /* number of chars written */
}       /* nCopyAnsiToWideChar */
------------------------------------------------------------------------------

This solves unwanted behavior problem for dialog titles (I had a
problem with russian characters in dialog title).

This also requires string

------------------------------------------------------------------------------
MultiByteToWideChar@24
------------------------------------------------------------------------------

to be added into $clean20root/Libraries/StdEnv 2.0/Clean System
Files/kernel_library

-- 
Best regards,
 Serguey
 thesz na mail tochka ru
 (na == at, tochka == dot)