private static ICharSequence EscapeChar(ICharSequence str, CultureInfo locale) { if (str == null || str.Length == 0) return str; ICharSequence buffer = str; // regular escapable Char for terms for (int i = 0; i < escapableTermChars.Length; i++) { buffer = ReplaceIgnoreCase(buffer, escapableTermChars[i].ToLower(locale), "\\", locale); } // First Character of a term as more escaping chars for (int i = 0; i < escapableTermExtraFirstChars.Length; i++) { if (buffer[0] == escapableTermExtraFirstChars[i][0]) { buffer = new StringCharSequenceWrapper("\\" + buffer[0] + buffer.SubSequence(1, buffer.Length).ToString()); break; } } return buffer; }
public ICharTermAttribute Append(ICharSequence csq, int start, int end) { if (csq == null) csq = new StringCharSequenceWrapper("null"); int len = end - start, csqlen = csq.Length; if (len < 0 || start > csqlen || end > csqlen) throw new IndexOutOfRangeException(); if (len == 0) return this; ResizeBuffer(TermLength + len); while (start < end) TermBuffer[TermLength++] = csq.CharAt(start++); return this; }