MCPcopy Create free account
hub / github.com/BaseXdb/basex / normEncoding

Method normEncoding

basex-core/src/main/java/org/basex/util/Strings.java:227–236  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 4

OutputSerializerMethod · 0.95
toEncodingOrNullMethod · 0.95
guessMethod · 0.80
encodingMethod · 0.80

Calls 2

eqMethod · 0.95
equalsMethod · 0.45

Tested by

no test coverage detected