MCPcopy Create free account
hub / github.com/java-native-access/jna / getCharset

Method getCharset

src/com/sun/jna/Native.java:465–481  ·  view source on GitHub ↗

Gets the charset belonging to the given encoding. @param encoding The encoding - if null then the default platform encoding is used. @return The charset belonging to the given encoding or the platform default. Never null.

(String encoding)

Source from the content-addressed store, hash-verified

463 * Never {@code null}.
464 */
465 private static Charset getCharset(String encoding) {
466 Charset charset = null;
467 if (encoding != null) {
468 try {
469 charset = Charset.forName(encoding);
470 }
471 catch(IllegalCharsetNameException | UnsupportedCharsetException e) {
472 LOG.log(Level.WARNING, "JNA Warning: Encoding ''{0}'' is unsupported ({1})",
473 new Object[]{encoding, e.getMessage()});
474 }
475 }
476 if (charset == null) {
477 LOG.log(Level.WARNING, "JNA Warning: Using fallback encoding {0}", Native.DEFAULT_CHARSET);
478 charset = Native.DEFAULT_CHARSET;
479 }
480 return charset;
481 }
482
483 /**
484 * Obtain a Java String from the given native byte array. If there is

Callers 3

toStringMethod · 0.95
getBytesMethod · 0.95
toByteArrayMethod · 0.95

Calls 1

logMethod · 0.45

Tested by

no test coverage detected