2 * Helper functions for ANSI<->UNICODE string conversion
4 * Copyright 2000 Hidenori Takeshima
16 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(imm
);
19 #include "imm_private.h"
22 INT
IMM32_strlenAtoW( LPCSTR lpstr
)
26 len
= MultiByteToWideChar( CP_ACP
, 0, lpstr
, -1, NULL
, 0 );
27 return ( len
> 0 ) ? (len
-1) : 0;
30 INT
IMM32_strlenWtoA( LPCWSTR lpwstr
)
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
)
43 len
= MultiByteToWideChar( CP_ACP
, 0, lpstr
, -1, lpwstr
, wbuflen
);
49 LPSTR
IMM32_strncpyWtoA( LPSTR lpstr
, LPCWSTR lpwstr
, INT abuflen
)
53 len
= WideCharToMultiByte( CP_ACP
, 0, lpwstr
, -1,
54 lpstr
, abuflen
, NULL
, NULL
);
60 LPWSTR
IMM32_strdupAtoW( LPCSTR lpstr
)
65 len
= IMM32_strlenAtoW( lpstr
);
68 lpwstr
= (LPWSTR
)IMM32_HeapAlloc( 0, sizeof(WCHAR
)*(len
+1) );
70 (void)IMM32_strncpyAtoW( lpwstr
, lpstr
, len
+1 );
76 LPSTR
IMM32_strdupWtoA( LPCWSTR lpwstr
)
81 len
= IMM32_strlenWtoA( lpwstr
);
84 lpstr
= (LPSTR
)IMM32_HeapAlloc( 0, sizeof(CHAR
)*(len
+1) );
86 (void)IMM32_strncpyWtoA( lpstr
, lpwstr
, len
+1 );