WCHAR ff_convert ( /* Converted code, 0 means conversion error */
WCHAR src, /* Character code to be converted */
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
)
{
const WCHAR *p;
WCHAR c;
int i, n, li, hi;
if (src < 0x80) { /* ASCII */
c = src;
} else {
if (dir) { /* OEMCP to unicode */
p = oem2uni;
hi = sizeof(oem2uni) / 4 - 1;
} else { /* Unicode to OEMCP */
p = uni2oem;
hi = sizeof(uni2oem) / 4 - 1;
}
li = 0;
for (n = 16; n; n--) {
i = li + (hi - li) / 2;
if (src == p[i * 2]) break;
if (src > p[i * 2])
li = i;
else
hi = i;
}
c = n ? p[i * 2 + 1] : 0;
}
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
WCHAR src, /* Character code to be converted */
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
)
{
const WCHAR *p;
WCHAR c;
int i, n, li, hi;
if (src < 0x80) { /* ASCII */
c = src;
} else {
if (dir) { /* OEMCP to unicode */
p = oem2uni;
hi = sizeof(oem2uni) / 4 - 1;
} else { /* Unicode to OEMCP */
p = uni2oem;
hi = sizeof(uni2oem) / 4 - 1;
}
li = 0;
for (n = 16; n; n--) {
i = li + (hi - li) / 2;
if (src == p[i * 2]) break;
if (src > p[i * 2])
li = i;
else
hi = i;
}
c = n ? p[i * 2 + 1] : 0;
}
return c;
}