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)
| 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 |
no test coverage detected