From 7df7e7ee65d7cb2037663a34d6b5e5438b643838 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sun, 10 Dec 2023 12:57:07 -0500 Subject: [PATCH] Use constant instead of magic string --- .../java/org/apache/commons/lang3/CharEncoding.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/CharEncoding.java b/src/main/java/org/apache/commons/lang3/CharEncoding.java index 621b44d8d..be3a27ba4 100644 --- a/src/main/java/org/apache/commons/lang3/CharEncoding.java +++ b/src/main/java/org/apache/commons/lang3/CharEncoding.java @@ -19,6 +19,7 @@ package org.apache.commons.lang3; import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.StandardCharsets; /** * Character encoding names required of every implementation of the Java platform. @@ -44,7 +45,7 @@ public class CharEncoding { * *

Every implementation of the Java platform is required to support this character encoding.

*/ - public static final String ISO_8859_1 = "ISO-8859-1"; + public static final String ISO_8859_1 = StandardCharsets.ISO_8859_1.name(); /** * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block @@ -52,7 +53,7 @@ public class CharEncoding { * *

Every implementation of the Java platform is required to support this character encoding.

*/ - public static final String US_ASCII = "US-ASCII"; + public static final String US_ASCII = StandardCharsets.US_ASCII.name(); /** * Sixteen-bit Unicode Transformation Format, byte order specified by a mandatory initial @@ -60,28 +61,28 @@ public class CharEncoding { * *

Every implementation of the Java platform is required to support this character encoding.

*/ - public static final String UTF_16 = "UTF-16"; + public static final String UTF_16 = StandardCharsets.UTF_16.name(); /** * Sixteen-bit Unicode Transformation Format, big-endian byte order. * *

Every implementation of the Java platform is required to support this character encoding.

*/ - public static final String UTF_16BE = "UTF-16BE"; + public static final String UTF_16BE = StandardCharsets.UTF_16BE.name(); /** * Sixteen-bit Unicode Transformation Format, little-endian byte order. * *

Every implementation of the Java platform is required to support this character encoding.

*/ - public static final String UTF_16LE = "UTF-16LE"; + public static final String UTF_16LE = StandardCharsets.UTF_16LE.name(); /** * Eight-bit Unicode Transformation Format. * *

Every implementation of the Java platform is required to support this character encoding.

*/ - public static final String UTF_8 = "UTF-8"; + public static final String UTF_8 = StandardCharsets.UTF_8.name(); /** * Returns whether the named charset is supported.