Просмотр исходного кода

add printUnicode methods in TextFormat

jieluo@google.com 11 лет назад
Родитель
Сommit
01283faa47
1 измененных файлов с 20 добавлено и 0 удалено
  1. 20 0
      java/src/main/java/com/google/protobuf/TextFormat.java

+ 20 - 0
java/src/main/java/com/google/protobuf/TextFormat.java

@@ -83,6 +83,26 @@ public final class TextFormat {
     DEFAULT_PRINTER.printUnknownFields(fields, new TextGenerator(output));
   }
 
+  /**
+   * Same as {@code print()}, except that non-ASCII characters are not
+   * escaped.
+   */
+  public static void printUnicode(
+      final MessageOrBuilder message, final Appendable output)
+      throws IOException {
+    UNICODE_PRINTER.print(message, new TextGenerator(output));
+  }
+
+  /**
+   * Same as {@code print()}, except that non-ASCII characters are not
+   * escaped.
+   */
+  public static void printUnicode(final UnknownFieldSet fields,
+                                  final Appendable output)
+                                  throws IOException {
+    UNICODE_PRINTER.printUnknownFields(fields, new TextGenerator(output));
+  }
+
   /**
    * Generates a human readable form of this message, useful for debugging and
    * other purposes, with no newline characters.