Java 类com.google.protobuf.Utf8.UnpairedSurrogateException 实例源码

项目:cfapi    文件:CodedOutputStream.java   
/** Write a {@code string} field to the stream. */
// TODO(dweis): Document behavior on ill-formed UTF-16 input.
public void writeStringNoTag(final String value) throws IOException {
  try {
    efficientWriteStringNoTag(value);
  } catch (UnpairedSurrogateException e) {
    logger.log(Level.WARNING, 
        "Converting ill-formed UTF-16. Your Protocol Buffer will not round trip correctly!", e);
    inefficientWriteStringNoTag(value);
  }
}
项目:cfapi    文件:CodedOutputStream.java   
/**
 * Compute the number of bytes that would be needed to encode a
 * {@code string} field.
 */
public static int computeStringSizeNoTag(final String value) {
  int length;
  try {
    length = Utf8.encodedLength(value);
  } catch (UnpairedSurrogateException e) {
    // TODO(dweis): Consider using nio Charset methods instead.
    final byte[] bytes = value.getBytes(Internal.UTF_8);
    length = bytes.length;
  }

  return computeRawVarint32Size(length) + length;
}
项目:play-store-api    文件:CodedOutputStream.java   
/**
 * Compute the number of bytes that would be needed to encode a
 * {@code string} field.
 */
public static int computeStringSizeNoTag(final String value) {
  int length;
  try {
    length = Utf8.encodedLength(value);
  } catch (UnpairedSurrogateException e) {
    // TODO(dweis): Consider using nio Charset methods instead.
    final byte[] bytes = value.getBytes(Internal.UTF_8);
    length = bytes.length;
  }

  return computeLengthDelimitedFieldSize(length);
}
项目:bazel    文件:CodedOutputStream.java   
/**
 * Compute the number of bytes that would be needed to encode a
 * {@code string} field.
 */
public static int computeStringSizeNoTag(final String value) {
  int length;
  try {
    length = Utf8.encodedLength(value);
  } catch (UnpairedSurrogateException e) {
    // TODO(dweis): Consider using nio Charset methods instead.
    final byte[] bytes = value.getBytes(Internal.UTF_8);
    length = bytes.length;
  }

  return computeLengthDelimitedFieldSize(length);
}