/** * Attempts to compose input by combining the first character * with the first combining mark following it. Returns a String * that is the composition of the leading character with its first * combining mark followed by the remaining combining marks. Returns * null if the first two characters cannot be further composed. */ private String composeOneStep(String input) { int len = countChars(input, 0, 2); String firstTwoCharacters = input.substring(0, len); String result = Normalizer.normalize(firstTwoCharacters, Normalizer.NFC); if (result.equals(firstTwoCharacters)) return null; else { String remainder = input.substring(len); return result + remainder; } }
/** * Attempts to compose input by combining the first character * with the first combining mark following it. Returns a String * that is the composition of the leading character with its first * combining mark followed by the remaining combining marks. Returns * null if the first two characters cannot be further composed. */ private String composeOneStep(String input) { int len = countChars(input, 0, 2); String firstTwoCharacters = input.substring(0, len); String result = Normalizer.normalize(firstTwoCharacters, Normalizer.NFC); if (result.equals(firstTwoCharacters)) return null; else { String remainder = input.substring(len); return result + remainder; } }
/** * Given a specific sequence composed of a regular character and * combining marks that follow it, produce the alternation that will * match all canonical equivalences of that sequence. */ private String produceEquivalentAlternation(String source) { int len = countChars(source, 0, 1); if (source.length() == len) // source has one character. return source; String base = source.substring(0,len); String combiningMarks = source.substring(len); String[] perms = producePermutations(combiningMarks); StringBuilder result = new StringBuilder(source); // Add combined permutations for(int x=0; x<perms.length; x++) { String next = base + perms[x]; if (x>0) result.append("|"+next); next = composeOneStep(next); if (next != null) result.append("|"+produceEquivalentAlternation(next)); } return result.toString(); }
/** * Given a specific sequence composed of a regular character and * combining marks that follow it, produce the alternation that will * match all canonical equivalences of that sequence. */ private String produceEquivalentAlternation(String source) { int len = countChars(source, 0, 1); if (source.length() == len) // source has one character. return source; String base = source.substring(0,len); String combiningMarks = source.substring(len); String[] perms = producePermutations(combiningMarks); StringBuilder result = new StringBuilder(source); // Add combined permutations for(int x=0; x<perms.length; x++) { String next = base + perms[x]; if (x>0) result.append("|"+next); next = composeOneStep(next); if (next != null) result.append("|"+produceEquivalentAlternation(next)); } return result.toString(); }
if (input.length() == countChars(input, 0, 1)) return new String[] {input}; if (input.length() == countChars(input, 0, 2)) { int c0 = Character.codePointAt(input, 0); int c1 = Character.codePointAt(input, Character.charCount(c0)); len = countChars(input, offset, 1); boolean skip = false; for(int y=x-1; y>=0; y--) {
if (input.length() == countChars(input, 0, 1)) return new String[] {input}; if (input.length() == countChars(input, 0, 2)) { int c0 = Character.codePointAt(input, 0); int c1 = Character.codePointAt(input, Character.charCount(c0)); len = countChars(input, offset, 1); boolean skip = false; for(int y=x-1; y>=0; y--) {