Przeglądaj źródła

add printUnicode methods in TextFormat

jieluo@google.com 11 lat temu
rodzic
commit
01283faa47

+ 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));
     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
    * Generates a human readable form of this message, useful for debugging and
    * other purposes, with no newline characters.
    * other purposes, with no newline characters.