2 * Helper functions for ANSI<->UNICODE string conversion
4 * Copyright 2000 Hidenori Takeshima
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(imm);
33 #include "imm_private.h"
36 INT IMM32_strlenAtoW( LPCSTR lpstr )
40 len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
41 return ( len > 0 ) ? (len-1) : 0;
44 INT IMM32_strlenWtoA( LPCWSTR lpwstr )
48 len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
49 NULL, 0, NULL, NULL );
50 return ( len > 0 ) ? (len-1) : 0;
53 LPWSTR IMM32_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
57 len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
63 LPSTR IMM32_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen )
67 len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
68 lpstr, abuflen, NULL, NULL );
74 LPWSTR IMM32_strdupAtoW( LPCSTR lpstr )
79 len = IMM32_strlenAtoW( lpstr );
82 lpwstr = (LPWSTR)IMM32_HeapAlloc( 0, sizeof(WCHAR)*(len+1) );
84 (void)IMM32_strncpyAtoW( lpwstr, lpstr, len+1 );
90 LPSTR IMM32_strdupWtoA( LPCWSTR lpwstr )
95 len = IMM32_strlenWtoA( lpwstr );
98 lpstr = (LPSTR)IMM32_HeapAlloc( 0, sizeof(CHAR)*(len+1) );
100 (void)IMM32_strncpyWtoA( lpstr, lpwstr, len+1 );