18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 25f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * its contributors may be used to endorse or promote products derived 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * from this software without specific prior written permission. 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef WTF_ASCIICType_h 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define WTF_ASCIICType_h 318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/Assertions.h> 338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// The behavior of many of the functions in the <ctype.h> header is dependent 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// on the current locale. But in the WebKit project, all uses of those functions 368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// are in code processing something that's not locale-specific. These equivalents 378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// for some of the <ctype.h> functions are named more explicitly, not dependent 388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// on the C library locale, and we should also optimize them as needed. 398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// All functions return false or leave the character unchanged if passed a character 418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// that is outside the range 0-7F. So they can be used on Unicode strings or 428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// characters if the intent is to do processing only if the character is ASCII. 438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace WTF { 458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 46635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project inline bool isASCII(char c) { return !(c & ~0x7F); } 47635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project inline bool isASCII(unsigned short c) { return !(c & ~0x7F); } 48635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 49635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project inline bool isASCII(wchar_t c) { return !(c & ~0x7F); } 50635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif 51635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project inline bool isASCII(int c) { return !(c & ~0x7F); } 52f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCII(unsigned c) { return !(c & ~0x7F); } 53635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlpha(char c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } 558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlpha(unsigned short c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } 568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlpha(wchar_t c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlpha(int c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } 60f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIAlpha(unsigned c) { return (c | 0x20) >= 'a' && (c | 0x20) <= 'z'; } 618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlphanumeric(char c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); } 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlphanumeric(unsigned short c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); } 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlphanumeric(wchar_t c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); } 668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIAlphanumeric(int c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); } 68f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIAlphanumeric(unsigned c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); } 698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIDigit(char c) { return (c >= '0') & (c <= '9'); } 718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIDigit(unsigned short c) { return (c >= '0') & (c <= '9'); } 728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIDigit(wchar_t c) { return (c >= '0') & (c <= '9'); } 748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIDigit(int c) { return (c >= '0') & (c <= '9'); } 76f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIDigit(unsigned c) { return (c >= '0') & (c <= '9'); } 778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIHexDigit(char c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f'); } 798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIHexDigit(unsigned short c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f'); } 808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIHexDigit(wchar_t c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f'); } 828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIHexDigit(int c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f'); } 84f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIHexDigit(unsigned c) { return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f'); } 858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIOctalDigit(char c) { return (c >= '0') & (c <= '7'); } 878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIOctalDigit(unsigned short c) { return (c >= '0') & (c <= '7'); } 888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIOctalDigit(wchar_t c) { return (c >= '0') & (c <= '7'); } 908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIOctalDigit(int c) { return (c >= '0') & (c <= '7'); } 92f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIOctalDigit(unsigned c) { return (c >= '0') & (c <= '7'); } 938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIILower(char c) { return c >= 'a' && c <= 'z'; } 958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIILower(unsigned short c) { return c >= 'a' && c <= 'z'; } 968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIILower(wchar_t c) { return c >= 'a' && c <= 'z'; } 988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIILower(int c) { return c >= 'a' && c <= 'z'; } 100f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIILower(unsigned c) { return c >= 'a' && c <= 'z'; } 1018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIUpper(char c) { return c >= 'A' && c <= 'Z'; } 1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIUpper(unsigned short c) { return c >= 'A' && c <= 'Z'; } 1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIUpper(wchar_t c) { return c >= 'A' && c <= 'Z'; } 1068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIUpper(int c) { return c >= 'A' && c <= 'Z'; } 108f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIUpper(unsigned c) { return c >= 'A' && c <= 'Z'; } 1098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project /* 1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project Statistics from a run of Apple's page load test for callers of isASCIISpace: 1128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project character count 1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project --------- ----- 1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project non-spaces 689383 1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 20 space 294720 1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 0A \n 89059 1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 09 \t 28320 1198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 0D \r 0 1208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 0C \f 0 1218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 0B \v 0 1228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 1238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIISpace(char c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } 1248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIISpace(unsigned short c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } 1258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 1268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIISpace(wchar_t c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } 1278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 1288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIISpace(int c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } 129f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIISpace(unsigned c) { return c <= ' ' && (c == ' ' || (c <= 0xD && c >= 0x9)); } 1308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline char toASCIILower(char c) { return c | ((c >= 'A' && c <= 'Z') << 5); } 1328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline unsigned short toASCIILower(unsigned short c) { return c | ((c >= 'A' && c <= 'Z') << 5); } 1338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 1348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline wchar_t toASCIILower(wchar_t c) { return c | ((c >= 'A' && c <= 'Z') << 5); } 1358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 1368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline int toASCIILower(int c) { return c | ((c >= 'A' && c <= 'Z') << 5); } 137f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline unsigned toASCIILower(unsigned c) { return c | ((c >= 'A' && c <= 'Z') << 5); } 1388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 139f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch // FIXME: Why do these need static_cast? 1408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline char toASCIIUpper(char c) { return static_cast<char>(c & ~((c >= 'a' && c <= 'z') << 5)); } 1418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline unsigned short toASCIIUpper(unsigned short c) { return static_cast<unsigned short>(c & ~((c >= 'a' && c <= 'z') << 5)); } 1428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 1438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline wchar_t toASCIIUpper(wchar_t c) { return static_cast<wchar_t>(c & ~((c >= 'a' && c <= 'z') << 5)); } 1448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 1458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline int toASCIIUpper(int c) { return static_cast<int>(c & ~((c >= 'a' && c <= 'z') << 5)); } 146f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline unsigned toASCIIUpper(unsigned c) { return static_cast<unsigned>(c & ~((c >= 'a' && c <= 'z') << 5)); } 1478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline int toASCIIHexValue(char c) { ASSERT(isASCIIHexDigit(c)); return c < 'A' ? c - '0' : (c - 'A' + 10) & 0xF; } 1498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline int toASCIIHexValue(unsigned short c) { ASSERT(isASCIIHexDigit(c)); return c < 'A' ? c - '0' : (c - 'A' + 10) & 0xF; } 1508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 1518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline int toASCIIHexValue(wchar_t c) { ASSERT(isASCIIHexDigit(c)); return c < 'A' ? c - '0' : (c - 'A' + 10) & 0xF; } 1528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 1538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline int toASCIIHexValue(int c) { ASSERT(isASCIIHexDigit(c)); return c < 'A' ? c - '0' : (c - 'A' + 10) & 0xF; } 154f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline int toASCIIHexValue(unsigned c) { ASSERT(isASCIIHexDigit(c)); return c < 'A' ? c - '0' : (c - 'A' + 10) & 0xF; } 1558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIPrintable(char c) { return c >= ' ' && c <= '~'; } 1578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIPrintable(unsigned short c) { return c >= ' ' && c <= '~'; } 1588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 1598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIPrintable(wchar_t c) { return c >= ' ' && c <= '~'; } 1608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 1618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project inline bool isASCIIPrintable(int c) { return c >= ' ' && c <= '~'; } 162f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch inline bool isASCIIPrintable(unsigned c) { return c >= ' ' && c <= '~'; } 1638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 1648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1655f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCII; 1665f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIAlpha; 1675f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIAlphanumeric; 1685f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIDigit; 1695f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIHexDigit; 1705f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIILower; 1715f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIOctalDigit; 1725f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIPrintable; 1735f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIISpace; 1745f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::isASCIIUpper; 1755f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::toASCIIHexValue; 1765f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::toASCIILower; 1775f1ab04193ad0130ca8204aadaceae083aca9881Feng Qianusing WTF::toASCIIUpper; 1785f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian 1798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif 180