2 * Unicode string management
4 * Copyright 1996 Martin von Loewis
6 * Conversion between Unicode and ISO-8859-1 is inherently lossy,
7 * so the conversion code should be called only if it does not matter
18 STRING32_UniLen(LPCWSTR s
)
26 void STRING32_UniToAnsi(LPSTR dest
,LPCWSTR src
)
28 static int have_warned
=0;
31 if(*src
>255 && !have_warned
)
33 fprintf(stderr
,"Cannot deal with non-ANSI characters\n");
38 /* copy the terminator */
42 /* FIXME: we need to use unsigned char here, for if
43 * we got chars with the 7th bit set, we will get
44 * negative integers -> wrong unicode values
47 STRING32_AnsiToUni(LPWSTR dest
,LPCSTR src
) {
50 usrc
=(unsigned char*)src
;
56 LPSTR
STRING32_DupUniToAnsi(LPCWSTR src
)
58 LPSTR dest
=xmalloc(STRING32_UniLen(src
)+1);
59 STRING32_UniToAnsi(dest
,src
);
63 LPWSTR
STRING32_DupAnsiToUni(LPCSTR src
)
65 LPWSTR dest
=xmalloc(2*strlen(src
)+2);
66 STRING32_AnsiToUni(dest
,src
);
70 DWORD
STRING32_lstrlenW(LPCWSTR str
)
78 /* not an API function */
80 WCHAR
STRING32_tolowerW(WCHAR c
)
86 int STRING32_lstrcmpniW(LPCWSTR a
,LPCWSTR b
,DWORD len
)
91 c1
= STRING32_tolowerW(*a
);
92 c2
= STRING32_tolowerW(*b
);
95 if(c1
==0 && c2
==0)return 0;
105 STRING32_lstrcmpW(LPCWSTR a
,LPCWSTR b
) {
110 if (diff
) return diff
;
120 STRING32_lstrchrW(LPCWSTR a
,WCHAR c
) {
130 STRING32_strdupW(LPCWSTR a
) {
134 len
=sizeof(WCHAR
)*(STRING32_UniLen(a
)+1);
135 b
=(LPWSTR
)xmalloc(len
);