4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_CHAR_UTIL_HPP
25 #define XCSOAR_CHAR_UTIL_HPP
33 IsASCII(const unsigned char ch
)
40 IsASCII(const char ch
)
42 return IsASCII((unsigned char)ch
);
48 IsASCII(const TCHAR ch
)
50 return (ch
& ~0x7f) == 0;
55 IsWhitespaceOrNull(const char ch
)
57 return (unsigned char)ch
<= 0x20;
61 IsWhitespaceNotNull(const char ch
)
63 return ch
> 0 && ch
<= 0x20;
69 IsWhitespaceOrNull(const TCHAR ch
)
71 return (unsigned)ch
<= 0x20;
75 IsWhitespaceNotNull(const TCHAR ch
)
77 return ch
> 0 && ch
<= 0x20;
84 IsPrintableASCII(char ch
)
86 return (signed char)ch
>= 0x20;
92 IsPrintableASCII(TCHAR ch
)
94 return IsASCII(ch
) && ch
>= 0x20;
100 IsDigitASCII(char ch
)
102 return ch
>= '0' && ch
<= '9';
107 IsUpperAlphaASCII(char ch
)
109 return ch
>= 'A' && ch
<= 'Z';
114 IsLowerAlphaASCII(char ch
)
116 return ch
>= 'a' && ch
<= 'z';
121 IsAlphaASCII(char ch
)
123 return IsUpperAlphaASCII(ch
) || IsLowerAlphaASCII(ch
);
128 IsAlphaNumericASCII(char ch
)
130 return IsAlphaASCII(ch
) || IsDigitASCII(ch
);
137 IsDigitASCII(TCHAR ch
)
139 return ch
>= _T('0') && ch
<= _T('9');
144 IsUpperAlphaASCII(TCHAR ch
)
146 return ch
>= _T('A') && ch
<= _T('Z');
151 IsLowerAlphaASCII(TCHAR ch
)
153 return ch
>= _T('a') && ch
<= _T('z');
158 IsAlphaASCII(TCHAR ch
)
160 return IsUpperAlphaASCII(ch
) || IsLowerAlphaASCII(ch
);
165 IsAlphaNumericASCII(TCHAR ch
)
167 return IsAlphaASCII(ch
) || IsDigitASCII(ch
);
173 * Convert the specified ASCII character (0x00..0x7f) to upper case.
174 * Unlike toupper(), it ignores the system locale.
178 ToUpperASCII(char ch
)
180 return ch
>= 'a' && ch
<= 'z'