src/rtlib/win32/intl_core.c
/* Convert a strings character set to another character set. */
Convert a strings character set to another character set.
Convert a strings character set to another character set .
static FBSTRING *fb_hIntlConvertToWC( FBSTRING *source, UINT source_cp )
{
    FBSTRING *res;
    int CharsRequired;
    FB_STRLOCK();
    CharsRequired =
        MultiByteToWideChar( source_cp,
                             0,
                             source->data,
                             FB_STRSIZE(source),
                             NULL,
                             0 );
    res = fb_hStrAllocTemp_NoLock( NULL, (CharsRequired + 1) * sizeof(WCHAR) - 1 );
    if( res!=NULL ) {
        size_t idx = CharsRequired * sizeof(WCHAR);
        MultiByteToWideChar( source_cp,
                             0,
                             (LPCSTR) source->data,
                             FB_STRSIZE(source),
                             (LPWSTR) res->data,
                             CharsRequired );
        *((WCHAR*) (res->data + idx)) = 0;
    } else {
        res = &__fb_ctx.null_desc;
    }
    fb_hStrDelTemp_NoLock( source );
    FB_STRUNLOCK();
    return res;
}
static FBSTRING * fb_hIntlConvertToWC ( FBSTRING * source , UINT source_cp ) { FBSTRING * res ; int CharsRequired ; FB_STRLOCK ( ) ; CharsRequired = MultiByteToWideChar ( source_cp , 0 , source -> data , FB_STRSIZE ( source ) , NULL , 0 ) ; res = fb_hStrAllocTemp_NoLock ( NULL , ( CharsRequired + 1 ) * sizeof ( WCHAR ) - 1 ) ; if ( res != NULL ) { size_t idx = CharsRequired * sizeof ( WCHAR ) ; MultiByteToWideChar ( source_cp , 0 , ( LPCSTR ) source -> data , FB_STRSIZE ( source ) , ( LPWSTR ) res -> data , CharsRequired ) ; * ( ( WCHAR * ) ( res -> data + idx ) ) = 0 ; } else { res = & __fb_ctx . null_desc ; } fb_hStrDelTemp_NoLock ( source ) ; FB_STRUNLOCK ( ) ; return res ; }
Convert a strings character set to another character set.
Convert a strings character set to another character set .