mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-07 22:19:12 +00:00
codepage.c: Define functions codepageMap and codepageConvert no more than once
This commit is contained in:
parent
4d45e55178
commit
7426853889
1 changed files with 10 additions and 15 deletions
|
@ -38,9 +38,11 @@
|
|||
# define WIN32_LEAN_AND_MEAN 1
|
||||
|
||||
# include <windows.h>
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
int
|
||||
codepageMap(int cp, int *map) {
|
||||
#if defined(_WIN32)
|
||||
int i;
|
||||
CPINFO info;
|
||||
if (! GetCPInfo(cp, &info) || info.MaxCharSize > 2)
|
||||
|
@ -68,32 +70,25 @@ codepageMap(int cp, int *map) {
|
|||
}
|
||||
}
|
||||
return 1;
|
||||
#else
|
||||
UNUSED_P(cp);
|
||||
UNUSED_P(map);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
codepageConvert(int cp, const char *p) {
|
||||
#if defined(_WIN32)
|
||||
unsigned short c;
|
||||
if (MultiByteToWideChar(cp, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, p, 2, &c,
|
||||
1)
|
||||
== 1)
|
||||
return c;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else /* not _WIN32 */
|
||||
|
||||
int
|
||||
codepageMap(int cp, int *map) {
|
||||
UNUSED_P(cp);
|
||||
UNUSED_P(map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
codepageConvert(int cp, const char *p) {
|
||||
#else
|
||||
UNUSED_P(cp);
|
||||
UNUSED_P(p);
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* not _WIN32 */
|
||||
|
|
Loading…
Add table
Reference in a new issue