/* ******************************************************************************* * Copyright (C) 2011, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* * created on: 2011feb25 * created by: Markus W. Scherer */ package com.ibm.icu.impl; /** * Implements the immutable Unicode properties Pattern_Syntax and Pattern_White_Space. * Hardcodes these properties, does not load data, does not depend on other ICU classes. *
* Note: Both properties include ASCII as well as non-ASCII, non-Latin-1 code points, * and both properties only include BMP code points (no supplementary ones). * Pattern_Syntax includes some unassigned code points. *
* [:Pattern_White_Space:] = * [\u0009-\u000D\ \u0085\u200E\u200F\u2028\u2029] *
* [:Pattern_Syntax:] =
* [!-/\:-@\[-\^`\{-~\u00A1-\u00A7\u00A9\u00AB\u00AC\u00AE
* \u00B0\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7
* \u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E
* \u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F
* \u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]
* @author mscherer
*/
public final class PatternProps {
/**
* @return true if c is a Pattern_Syntax code point.
*/
public static boolean isSyntax(int c) {
if(c<0) {
return false;
} else if(c<=0xff) {
return latin1[c]==3;
} else if(c<0x2010) {
return false;
} else if(c<=0x3030) {
int bits=syntax2000[index2000[(c-0x2000)>>5]];
return ((bits>>(c&0x1f))&1)!=0;
} else if(0xfd3e<=c && c<=0xfe46) {
return c<=0xfd3f || 0xfe45<=c;
} else {
return false;
}
}
/**
* @return true if c is a Pattern_Syntax or Pattern_White_Space code point.
*/
public static boolean isSyntaxOrWhiteSpace(int c) {
if(c<0) {
return false;
} else if(c<=0xff) {
return latin1[c]!=0;
} else if(c<0x200e) {
return false;
} else if(c<=0x3030) {
int bits=syntaxOrWhiteSpace2000[index2000[(c-0x2000)>>5]];
return ((bits>>(c&0x1f))&1)!=0;
} else if(0xfd3e<=c && c<=0xfe46) {
return c<=0xfd3f || 0xfe45<=c;
} else {
return false;
}
}
/**
* @return true if c is a Pattern_White_Space character.
*/
public static boolean isWhiteSpace(int c) {
if(c<0) {
return false;
} else if(c<=0xff) {
return latin1[c]==5;
} else if(0x200e<=c && c<=0x2029) {
return c<=0x200f || 0x2028<=c;
} else {
return false;
}
}
/**
* Skips over Pattern_White_Space starting at index i of the CharSequence.
* @return The smallest index at or after i with a non-white space character.
*/
public static int skipWhiteSpace(CharSequence s, int i) {
while(i