Use GetStringTypeW() for implementation of IsCharAlphaNumericW(),

IsCharAlphaW(), IsCharLowerW() and IsCharUpperW()

svn path=/trunk/; revision=11187
This commit is contained in:
Gé van Geldorp 2004-10-04 19:22:16 +00:00
parent 7e15de6d4a
commit aa496615df

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: text.c,v 1.11 2004/08/22 20:51:57 navaraf Exp $ /* $Id: text.c,v 1.12 2004/10/04 19:22:16 gvg Exp $
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c * FILE: lib/user32/windows/input.c
@ -32,22 +32,22 @@
#include <ctype.h> #include <ctype.h>
#include <debug.h> #include <debug.h>
const unsigned short wctype_table[] =
{
};
/* the character type contains the C1_* flags in the low 12 bits */
/* and the C2_* type in the high 4 bits */
static inline unsigned short get_char_typeW(WCHAR ch)
{
extern const unsigned short wctype_table[];
return wctype_table[wctype_table[ch >> 8] + (ch & 0xff)];
}
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
//LPSTR STDCALL CharLowerA(LPSTR lpsz) static WORD
GetC1Type(WCHAR Ch)
{
WORD CharType;
if (! GetStringTypeW(CT_CTYPE1, &Ch, 1, &CharType))
{
return 0;
}
return CharType;
}
/* /*
* @implemented * @implemented
*/ */
@ -76,7 +76,6 @@ CharLowerA(LPSTR x)
return x; return x;
} }
//DWORD STDCALL CharLowerBuffA(LPSTR lpsz, DWORD cchLength)
/* /*
* @implemented * @implemented
*/ */
@ -100,7 +99,6 @@ CharLowerBuffA(LPSTR str, DWORD len)
return 0; return 0;
} }
//DWORD STDCALL CharLowerBuffW(LPWSTR lpsz, DWORD cchLength)
/* /*
* @implemented * @implemented
*/ */
@ -114,7 +112,6 @@ CharLowerBuffW(LPWSTR str, DWORD len)
return ret; return ret;
} }
//LPWSTR STDCALL CharLowerW(LPWSTR lpsz)
/* /*
* @implemented * @implemented
*/ */
@ -129,7 +126,6 @@ CharLowerW(LPWSTR x)
} }
} }
//LPWSTR STDCALL CharPrevW(LPCWSTR lpszStart, LPCWSTR lpszCurrent)
/* /*
* @implemented * @implemented
*/ */
@ -141,7 +137,6 @@ CharPrevW(LPCWSTR start, LPCWSTR x)
else return (LPWSTR)x; else return (LPWSTR)x;
} }
//LPSTR STDCALL CharNextA(LPCSTR lpsz)
/* /*
* @implemented * @implemented
*/ */
@ -154,7 +149,6 @@ CharNextA(LPCSTR ptr)
return (LPSTR)(ptr + 1); return (LPSTR)(ptr + 1);
} }
//LPSTR STDCALL CharNextExA(WORD CodePage, LPCSTR lpCurrentChar, DWORD dwFlags)
/* /*
* @implemented * @implemented
*/ */
@ -167,7 +161,6 @@ CharNextExA(WORD codepage, LPCSTR ptr, DWORD flags)
return (LPSTR)(ptr + 1); return (LPSTR)(ptr + 1);
} }
//LPWSTR STDCALL CharNextW(LPCWSTR lpsz)
/* /*
* @implemented * @implemented
*/ */
@ -179,7 +172,6 @@ CharNextW(LPCWSTR x)
return (LPWSTR)x; return (LPWSTR)x;
} }
//LPSTR STDCALL CharPrevA(LPCSTR lpszStart, LPCSTR lpszCurrent)
/* /*
* @implemented * @implemented
*/ */
@ -195,7 +187,6 @@ CharPrevA(LPCSTR start, LPCSTR ptr)
return (LPSTR)start; return (LPSTR)start;
} }
//LPSTR STDCALL CharPrevExA(WORD CodePage, LPCSTR lpStart, LPCSTR lpCurrentChar, DWORD dwFlags)
/* /*
* @implemented * @implemented
*/ */
@ -210,7 +201,6 @@ LPSTR WINAPI CharPrevExA( WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags )
return (LPSTR)start; return (LPSTR)start;
} }
//BOOL STDCALL CharToOemA(LPCSTR lpszSrc, LPSTR lpszDst)
/* /*
* @implemented * @implemented
*/ */
@ -222,7 +212,6 @@ CharToOemA(LPCSTR s, LPSTR d)
return CharToOemBuffA(s, d, strlen(s) + 1); return CharToOemBuffA(s, d, strlen(s) + 1);
} }
//BOOL STDCALL CharToOemBuffA(LPCSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength)
/* /*
* @implemented * @implemented
*/ */
@ -241,7 +230,6 @@ CharToOemBuffA(LPCSTR s, LPSTR d, DWORD len)
return TRUE; return TRUE;
} }
//BOOL STDCALL CharToOemBuffW(LPCWSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength)
/* /*
* @implemented * @implemented
*/ */
@ -255,7 +243,6 @@ CharToOemBuffW(LPCWSTR s, LPSTR d, DWORD len)
return TRUE; return TRUE;
} }
//BOOL STDCALL CharToOemW(LPCWSTR lpszSrc, LPSTR lpszDst)
/* /*
* @implemented * @implemented
*/ */
@ -266,7 +253,6 @@ CharToOemW(LPCWSTR s, LPSTR d)
return CharToOemBuffW(s, d, wcslen(s) + 1); return CharToOemBuffW(s, d, wcslen(s) + 1);
} }
//LPSTR STDCALL CharUpperA(LPSTR lpsz)
/* /*
* @implemented * @implemented
*/ */
@ -277,7 +263,6 @@ LPSTR WINAPI CharUpperA(LPSTR x)
return x; return x;
} }
//DWORD STDCALL CharUpperBuffA(LPSTR lpsz, DWORD cchLength)
/* /*
* @implemented * @implemented
*/ */
@ -301,7 +286,6 @@ CharUpperBuffA(LPSTR str, DWORD len)
return 0; return 0;
} }
//DWORD STDCALL CharUpperBuffW(LPWSTR lpsz, DWORD cchLength)
/* /*
* @implemented * @implemented
*/ */
@ -315,7 +299,6 @@ CharUpperBuffW(LPWSTR str, DWORD len)
return ret; return ret;
} }
//LPWSTR STDCALL CharUpperW(LPWSTR lpsz)
/* /*
* @implemented * @implemented
*/ */
@ -327,39 +310,17 @@ CharUpperW(LPWSTR x)
else return (LPWSTR)(UINT)towlower((WORD)(((DWORD)(x)) & 0xFFFF)); else return (LPWSTR)(UINT)towlower((WORD)(((DWORD)(x)) & 0xFFFF));
} }
//BOOL STDCALL IsCharAlphaA(CHAR ch)
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
IsCharAlphaA(CHAR x) IsCharAlphaA(CHAR Ch)
{ {
WCHAR wch; WCHAR WCh;
MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
return IsCharAlphaW(wch);
}
const char IsCharAlphaNumericA_lookup_table[] = { MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x03, return IsCharAlphaW(WCh);
0xfe, 0xff, 0xff, 0x07, 0xfe, 0xff, 0xff, 0x07,
0x08, 0x54, 0x00, 0xd4, 0x00, 0x00, 0x0c, 0x02,
0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff
};
/*
* @implemented
*/
BOOL
STDCALL
IsCharAlphaNumericA(CHAR ch)
{
// return (IsCharAlphaNumericA_lookup_table[ch / 8] & (1 << (ch % 8))) ? 1 : 0;
WCHAR wch;
MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
return IsCharAlphaNumericW(wch);
//return FALSE;
} }
/* /*
@ -367,72 +328,80 @@ IsCharAlphaNumericA(CHAR ch)
*/ */
BOOL BOOL
STDCALL STDCALL
IsCharAlphaNumericW(WCHAR ch) IsCharAlphaNumericA(CHAR Ch)
{ {
return (get_char_typeW(ch) & (C1_ALPHA|C1_DIGIT)) != 0; WCHAR WCh;
// return FALSE;
MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
return IsCharAlphaNumericW(WCh);
}
/*
* @implemented
*/
BOOL
STDCALL
IsCharAlphaNumericW(WCHAR Ch)
{
return (GetC1Type(Ch) & (C1_ALPHA|C1_DIGIT)) != 0;
} }
//BOOL STDCALL IsCharAlphaW(WCHAR ch)
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
IsCharAlphaW(WCHAR x) IsCharAlphaW(WCHAR Ch)
{ {
return (get_char_typeW(x) & C1_ALPHA) != 0; return (GetC1Type(Ch) & C1_ALPHA) != 0;
} }
//BOOL STDCALL IsCharLowerA(CHAR ch)
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
IsCharLowerA(CHAR x) IsCharLowerA(CHAR Ch)
{ {
WCHAR wch; WCHAR WCh;
MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
return IsCharLowerW(wch); MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
return IsCharLowerW(WCh);
} }
//BOOL STDCALL IsCharLowerW(WCHAR ch)
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
IsCharLowerW(WCHAR x) IsCharLowerW(WCHAR Ch)
{ {
return (get_char_typeW(x) & C1_LOWER) != 0; return (GetC1Type(Ch) & C1_LOWER) != 0;
} }
//BOOL STDCALL IsCharUpperA(CHAR ch)
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
IsCharUpperA(CHAR x) IsCharUpperA(CHAR Ch)
{ {
WCHAR wch; WCHAR WCh;
MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
return IsCharUpperW(wch); MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
return IsCharUpperW(WCh);
} }
//BOOL STDCALL IsCharUpperW(WCHAR ch)
/* /*
* @implemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
IsCharUpperW(WCHAR x) IsCharUpperW(WCHAR Ch)
{ {
return (get_char_typeW(x) & C1_UPPER) != 0; return (GetC1Type(Ch) & C1_UPPER) != 0;
} }
//BOOL STDCALL OemToCharA(LPCSTR lpszSrc, LPSTR lpszDst)
/* /*
* @implemented * @implemented
*/ */
@ -443,7 +412,6 @@ OemToCharA(LPCSTR s, LPSTR d)
return OemToCharBuffA(s, d, strlen(s) + 1); return OemToCharBuffA(s, d, strlen(s) + 1);
} }
//BOOL STDCALL OemToCharBuffA(LPCSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength)
/* /*
* @implemented * @implemented
*/ */
@ -460,7 +428,6 @@ BOOL WINAPI OemToCharBuffA(LPCSTR s, LPSTR d, DWORD len)
return TRUE; return TRUE;
} }
//BOOL STDCALL OemToCharBuffW(LPCSTR lpszSrc, LPWSTR lpszDst, DWORD cchDstLength)
/* /*
* @implemented * @implemented
*/ */
@ -472,7 +439,6 @@ OemToCharBuffW(LPCSTR s, LPWSTR d, DWORD len)
return TRUE; return TRUE;
} }
//BOOL STDCALL OemToCharW(LPCSTR lpszSrc, LPWSTR lpszDst)
/* /*
* @implemented * @implemented
*/ */
@ -480,3 +446,5 @@ BOOL WINAPI OemToCharW(LPCSTR s, LPWSTR d)
{ {
return OemToCharBuffW(s, d, strlen(s) + 1); return OemToCharBuffW(s, d, strlen(s) + 1);
} }
/* EOF */