Returns a unified representation of the specified encoding. @param encoding input encoding (can be null) @param dflt return default values if supplied encoding is null or ambiguous @return encoding or null
(final String encoding, final boolean dflt)
| 225 | * @return encoding or {@code null} |
| 226 | */ |
| 227 | public static String normEncoding(final String encoding, final boolean dflt) { |
| 228 | if(encoding == null) return dflt ? UTF8 : null; |
| 229 | final String e = encoding.toUpperCase(Locale.ENGLISH); |
| 230 | if(eq(e, ALL_UTF8)) return UTF8; |
| 231 | if(e.equals(UTF16LE)) return UTF16LE; |
| 232 | if(e.equals(UTF16BE)) return UTF16BE; |
| 233 | if(eq(e, ALL_UTF16)) return dflt ? UTF16BE : UTF16; |
| 234 | if(eq(e, ALL_UTF32)) return UTF32; |
| 235 | return encoding; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Checks if the specified encoding is supported. |
no test coverage detected