### Question:
CharsetHelper { @Nullable public static String getAsStringInOtherCharset (@Nullable final String sText, @Nonnull final Charset aCurrentCharset, @Nonnull final Charset aNewCharset) { ValueEnforcer.notNull (aCurrentCharset, "CurrentCharset"); ValueEnforcer.notNull (aNewCharset, "NewCharset"); if (sText == null || aCurrentCharset.equals (aNewCharset)) return sText; return new String (sText.getBytes (aCurrentCharset), aNewCharset); } private  CharsetHelper(); @Nonnull static Charset getCharsetFromName(@Nonnull @Nonempty final String sCharsetName); @Nullable static Charset getCharsetFromNameOrNull(@Nullable final String sCharsetName); @Nullable static Charset getCharsetFromNameOrDefault(@Nullable final String sCharsetName, @Nullable final Charset aDefault); @Nonnull @ReturnsMutableCopy static ICommonsOrderedMap <String, Charset> getAllCharsets(); @Nullable static String getAsStringInOtherCharset(@Nullable final String sText,
                                                  @Nonnull final Charset aCurrentCharset,
                                                  @Nonnull final Charset aNewCharset); @Nonnegative static int getUTF8ByteCount(@Nullable final String s); @Nonnegative static int getUTF8ByteCount(@Nullable final char [] aChars); @Nonnegative static int getUTF8ByteCount(final char c); @Nonnegative static int getUTF8ByteCount(@Nonnegative final int c); @Nonnull static InputStreamAndCharset getInputStreamAndCharsetFromBOM(@Nonnull @WillNotClose final InputStream aIS); @Nonnull static InputStreamReader getReaderByBOM(@Nonnull final InputStream aIS, @Nonnull final Charset aFallbackCharset);  }### Answer:
@Test public void testGetAsStringInOtherCharsetCharset () { final String s = "äbc"; assertEquals (3, CharsetHelper.getAsStringInOtherCharset (s, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8).length ()); assertEquals (4, CharsetHelper.getAsStringInOtherCharset (s, StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1).length ()); assertNull (CharsetHelper.getAsStringInOtherCharset (null, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8)); assertEquals (s, CharsetHelper.getAsStringInOtherCharset (s, StandardCharsets.ISO_8859_1, StandardCharsets.ISO_8859_1)); assertEquals (s, CharsetHelper.getAsStringInOtherCharset (s, StandardCharsets.UTF_8, StandardCharsets.UTF_8)); try { CharsetHelper.getAsStringInOtherCharset (s, null, StandardCharsets.UTF_8); fail (); } catch (final NullPointerException ex) {} try { CharsetHelper.getAsStringInOtherCharset (s, StandardCharsets.ISO_8859_1, null); fail (); } catch (final NullPointerException ex) {} }