Added support for backslash escaping of special characters.
[wine.git] / dlls / imm32 / string.c
blob8abc91a1b0bed7a0fc447be7651d0265a6707158
1 /*
2 * Helper functions for ANSI<->UNICODE string conversion
4 * Copyright 2000 Hidenori Takeshima
5 */
7 #include "config.h"
9 #include "winbase.h"
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "winuser.h"
13 #include "winerror.h"
14 #include "winnls.h"
15 #include "immddk.h"
16 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(imm);
19 #include "imm_private.h"
22 INT IMM32_strlenAtoW( LPCSTR lpstr )
24 INT len;
26 len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, NULL, 0 );
27 return ( len > 0 ) ? (len-1) : 0;
30 INT IMM32_strlenWtoA( LPCWSTR lpwstr )
32 INT len;
34 len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
35 NULL, 0, NULL, NULL );
36 return ( len > 0 ) ? (len-1) : 0;
39 LPWSTR IMM32_strncpyAtoW( LPWSTR lpwstr, LPCSTR lpstr, INT wbuflen )
41 INT len;
43 len = MultiByteToWideChar( CP_ACP, 0, lpstr, -1, lpwstr, wbuflen );
44 if ( len == 0 )
45 *lpwstr = 0;
46 return lpwstr;
49 LPSTR IMM32_strncpyWtoA( LPSTR lpstr, LPCWSTR lpwstr, INT abuflen )
51 INT len;
53 len = WideCharToMultiByte( CP_ACP, 0, lpwstr, -1,
54 lpstr, abuflen, NULL, NULL );
55 if ( len == 0 )
56 *lpstr = 0;
57 return lpstr;
60 LPWSTR IMM32_strdupAtoW( LPCSTR lpstr )
62 INT len;
63 LPWSTR lpwstr = NULL;
65 len = IMM32_strlenAtoW( lpstr );
66 if ( len > 0 )
68 lpwstr = (LPWSTR)IMM32_HeapAlloc( 0, sizeof(WCHAR)*(len+1) );
69 if ( lpwstr != NULL )
70 (void)IMM32_strncpyAtoW( lpwstr, lpstr, len+1 );
73 return lpwstr;
76 LPSTR IMM32_strdupWtoA( LPCWSTR lpwstr )
78 INT len;
79 LPSTR lpstr = NULL;
81 len = IMM32_strlenWtoA( lpwstr );
82 if ( len > 0 )
84 lpstr = (LPSTR)IMM32_HeapAlloc( 0, sizeof(CHAR)*(len+1) );
85 if ( lpstr != NULL )
86 (void)IMM32_strncpyWtoA( lpstr, lpwstr, len+1 );
89 return lpstr;