java.lang.StringBuilder.codePointAt()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中java.lang.StringBuilder.codePointAt()方法的一些代码示例,展示了StringBuilder.codePointAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuilder.codePointAt()方法的具体详情如下:
包路径:java.lang.StringBuilder
类名称:StringBuilder
方法名:codePointAt

StringBuilder.codePointAt介绍

暂无

代码示例

代码示例来源:origin: JasonQS/Anti-recall

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();
  }
}

代码示例来源:origin: crashub/crash

buffer[i] = sb.codePointAt(i);

代码示例来源:origin: org.opencypher/grammar

@Override
public int codePointAt( int index )
{
  return output.codePointAt( index );
}

代码示例来源:origin: me.soliveirajr/menta-bean

public int codePointAt(int index) {
  return sb.codePointAt(index);
}

代码示例来源:origin: jp.dodododo/samurai-dao

public int codePointAt(int index) {
  return delegator.codePointAt(index);
}

代码示例来源:origin: org.fuwjin/grin

int codePointAt(final int index) {
 return builder.codePointAt(index);
}

代码示例来源:origin: com.github.javaito/hcjf

public int codePointAt(int index) {
  return builder.codePointAt(index);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

int next() {
  int c = oldBuffer.codePointAt(pos);
  pos += Character.charCount(c);
  return c;
}

代码示例来源:origin: jpcsp/jpcsp

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]);
  }
}

代码示例来源:origin: cflint/CFLint

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();
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Override
@JTranscAsync
public synchronized int codePointAt(int index) {
  return super.codePointAt(index);
}

代码示例来源:origin: cflint/CFLint

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();
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * 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;
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** 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();
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/**
 * 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;
  }
}

代码示例来源:origin: edu.ucar/netcdf

/**
 * 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();
}

代码示例来源:origin: omegat-org/omegat

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;
}

代码示例来源:origin: omegat-org/omegat

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;
}

代码示例来源:origin: omegat-org/omegat

/**
 * Finds the Xtag corresponding to an OmegaT tag
 *
 * @param tag
 *            OmegaT tag, without &lt; and &gt;
 * @return either the original Xtag, or the tag with &lt; and &gt;
 *         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();
}

代码示例来源:origin: com.sqlapp/sqlapp-core

/**
 * 表示上の幅を取得します。
 * @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;
}

相关文章

微信公众号

最新文章

更多