Bonjour,
Oui, le code a quelques problèmes:
1 2 3 4 5 6
| #include <windows.h>
//ANSI->Unicode
LPCSTR szAnsi = "C:\file1\object1!Object2";
int Size = MultiByteToWideChar (CP_ACP, 0, szAnsi, -1, NULL, 0);
LPWSTR wUnicode = new WCHAR[Size];
MultiByteToWideChar (CP_ACP, 0, szAnsi, -1, wUnicode, Size); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| 08-08-19.c:6:17: warning: unknown escape sequence '\o'
08-08-19.c:7: error: initializer element is not constant
08-08-19.c:8: error: `new' undeclared here (not in a function)
08-08-19.c:8: error: parse error before "WCHAR"
08-08-19.c:9: error: parse error before numeric constant
08-08-19.c:9: warning: type defaults to `int' in declaration of `MultiByteToWide Char'
08-08-19.c:9: error: conflicting types for 'MultiByteToWide
Char'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winnls.h:621: error
: previous declaration of 'MultiByteToWideChar' was here
08-08-19.c:9: error: conflicting types for 'MultiByteToWideChar'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winnls.h:621: error
: previous declaration of 'MultiByteToWideChar' was here
08-08-19.c:9: warning: data definition has no type or storage class |
Alors, ligne par ligne :
LPCSTR szAnsi = "C:\file1\object1!Object2";
'\f' et '\o' ne code pas un antislash. Pour écrire un antislsh, on écrit '\\'
--EDIT--
Size n'est pas constant, on ne peut donc pas s'en servir pour un allocation derrière
LPWSTR wUnicode = new WCHAR[Size];
c++ ?
On écrira plutôt WCHAR wUnicode[64] = L"";
Partager