public static String replaceFace(String s) { int indexOfPrefix = -1; StringBuilder sb = new StringBuilder(s); while ((indexOfPrefix = sb.indexOf(prefix, indexOfPrefix + 1)) > -1) { int index = sb.codePointAt(indexOfPrefix + 1); Log.e(TAG, "addMsg: s: " + s); Log.e(TAG, "addMsg: " + index); Log.e(TAG, "addMsg: indexOfPrefix: " + indexOfPrefix); Log.e(TAG, "addMsg: length: " + s.length()); sb.replace(indexOfPrefix, indexOfPrefix + 2, strings[index]); } return sb.toString(); } }
buffer[i] = sb.codePointAt(i);
@Override public int codePointAt( int index ) { return output.codePointAt( index ); }
public int codePointAt(int index) { return sb.codePointAt(index); }
public int codePointAt(int index) { return delegator.codePointAt(index); }
int codePointAt(final int index) { return builder.codePointAt(index); }
public int codePointAt(int index) { return builder.codePointAt(index); }
int next() { int c = oldBuffer.codePointAt(pos); pos += Character.charCount(c); return c; }
private static void replaceFullWidthChar(StringBuilder s, int index, int codePointOffset) { int codePoint = s.codePointAt(index); char chars[] = new char[2]; if (Character.toChars(codePoint + codePointOffset, chars, 0) == 1) { s.setCharAt(index, chars[0]); } }
private String escapeControlCharacters(final String value) { StringBuilder sb = new StringBuilder(value); for (int i = 0; i < sb.length(); i++) { final int codePoint = sb.codePointAt(i); if (Character.isISOControl(codePoint)) { final String encode = UnicodeCharEncoder.encode(codePoint); sb.replace(i, i + 1, encode); } } return sb.toString(); }
@Override @JTranscAsync public synchronized int codePointAt(int index) { return super.codePointAt(index); }
private String escapeControlCharacters(final String value) { StringBuilder sb = new StringBuilder(value); for (int i = 0; i < sb.length(); i++) { final int codePoint = sb.codePointAt(i); if (Character.isISOControl(codePoint)) { final String encode = UnicodeCharEncoder.encode(codePoint); sb.replace(i, i + 1, encode); } } return sb.toString(); }
/** * Return the current character in the normalized text. * @return The codepoint as an int * @deprecated ICU 56 */ @Deprecated public int current() { if(bufferPos<buffer.length() || nextNormalize()) { return buffer.codePointAt(bufferPos); } else { return DONE; } }
/** merges paths using forward slash as the "local OS file separator", because it is recognised on windows, * making paths more consistent and avoiding problems with backslashes being escaped. * empty segments are omitted. */ public static String mergePaths(String ...items) { char separatorChar = '/'; StringBuilder result = new StringBuilder(); for (String item: items) { if (Strings.isEmpty(item)) continue; if (result.length() > 0 && !isSeparator(result.codePointAt(result.length()-1))) result.append(separatorChar); result.append(item); } return result.toString(); }
/** * Return the next character in the normalized text and advance * the iteration position by one. If the end * of the text has already been reached, {@link #DONE} is returned. * @return The codepoint as an int * @deprecated ICU 56 */ @Deprecated public int next() { if(bufferPos<buffer.length() || nextNormalize()) { int c=buffer.codePointAt(bufferPos); bufferPos+=Character.charCount(c); return c; } else { return DONE; } }
/** * Convert a name to a legal netcdf-3 name. * @param name convert this name * @return converted name */ static public String makeValidNetcdfObjectName(String name) { StringBuilder sb = new StringBuilder(name.trim()); // remove starting and trailing blanks while (sb.length() > 0) { char c = sb.charAt(0); if (Character.isLetter(c) || Character.isDigit(c) || (c == '_')) break; sb.deleteCharAt(0); } int pos = 1; while (pos < sb.length()) { int c = sb.codePointAt(pos); if (((c >= 0) && (c < 0x20)) || (c == 0x2f) || (c == 0x7f)) { sb.delete(pos, pos + 1); pos--; } pos++; } if (sb.length() == 0) throw new IllegalArgumentException("Illegal name"); return sb.toString(); }
boolean isSpaces(Token token) { for (int cp, i = 0; i < token.getLength(); i += Character.charCount(cp)) { cp = str.codePointAt(token.getOffset() + i); if (!Character.isWhitespace(cp)) { return false; } } return true; }
boolean isPossibleBreakBefore(int pos) { try { // check previous char. Can't split after specified chars. int cp = str.codePointBefore(pos); // U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK // U+201E DOUBLE LOW-9 QUOTATION MARK if (":\\([{<\u00ab\u201e".indexOf(cp) >= 0) { return false; } } catch (StringIndexOutOfBoundsException ex) { } try { // check next char. Can't split before specified chars. int cp = str.codePointAt(pos); // U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK // U+201C LEFT DOUBLE QUOTATION MARK if ("{:)]}>\u00bb\u201c,.".indexOf(cp) >= 0) { return false; } } catch (StringIndexOutOfBoundsException ex) { } return true; }
/** * Finds the Xtag corresponding to an OmegaT tag * * @param tag * OmegaT tag, without < and > * @return either the original Xtag, or the tag with < and > * characters converted to the Xtag equivalent */ private String findTag(StringBuilder tag) { for (Xtag oneTag : listTags) { if (oneTag.toShortcut().equals(tag.toString())) { return oneTag.toOriginal(); } } // It was not a real tag // We must convert < to <\<> and > to <\>> StringBuilder changedString = new StringBuilder(); for (int cp, i = 0; i < tag.length(); i += Character.charCount(cp)) { cp = tag.codePointAt(i); changedString.append(convertSpecialCharacter(cp)); } return changedString.toString(); }
/** * 表示上の幅を取得します。 * @param val */ public static int getDisplayWidth(StringBuilder val){ if (val ==null){ return 0; } int count=0; int i=0; int codePointLen=val.codePointCount(0, val.length()); while(i<codePointLen){ int codePoint=val.codePointAt(i++); if (isHalf(codePoint)){ count++; } else{ count=count+2; } } return count; }