Skip to content

Commit

Permalink
Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 11, 2024
1 parent 23f0816 commit ccb13fb
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions src/main/java/org/apache/commons/lang3/StringEscapeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,28 +584,46 @@ public static final String escapeXml(final String input) {

/**
* Escapes the characters in a {@link String} using XML entities.
* <p>
* For example:
* </p>
*
* <p>For example: {@code "bread" & "butter"} =&gt;
* {@code &quot;bread&quot; &amp; &quot;butter&quot;}.
* <pre>{@code
* "bread" & "butter"
* }</pre>
* <p>
* converts to:
* </p>
*
* <p>Note that XML 1.0 is a text-only format: it cannot represent control
* characters or unpaired Unicode surrogate code points, even after escaping.
* {@code escapeXml10} will remove characters that do not fit in the
* following ranges:</p>
* <pre>
* {@code
* &quot;bread&quot; &amp; &quot;butter&quot;
* }
* </pre>
*
* <p>
* Note that XML 1.0 is a text-only format: it cannot represent control characters or unpaired Unicode surrogate code points, even after escaping. The
* method {@code escapeXml10} will remove characters that do not fit in the following ranges:
* </p>
*
* <p>{@code #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]}</p>
* <p>
* {@code #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]}
* </p>
*
* <p>Though not strictly necessary, {@code escapeXml10} will escape
* characters in the following ranges:</p>
* <p>
* Though not strictly necessary, {@code escapeXml10} will escape characters in the following ranges:
* </p>
*
* <p>{@code [#x7F-#x84] | [#x86-#x9F]}</p>
* <p>
* {@code [#x7F-#x84] | [#x86-#x9F]}
* </p>
*
* <p>The returned string can be inserted into a valid XML 1.0 or XML 1.1
* document. If you want to allow more non-text characters in an XML 1.1
* document, use {@link #escapeXml11(String)}.</p>
* <p>
* The returned string can be inserted into a valid XML 1.0 or XML 1.1 document. If you want to allow more non-text characters in an XML 1.1 document, use
* {@link #escapeXml11(String)}.
* </p>
*
* @param input the {@link String} to escape, may be null
* @param input the {@link String} to escape, may be null
* @return a new escaped {@link String}, {@code null} if null string input
* @see #unescapeXml(String)
* @since 3.3
Expand Down

0 comments on commit ccb13fb

Please sign in to comment.