@Test public void toUTF8_crtEncodingIsSupersetOfUTF8AndStrDoesNotContainsSupersetChars_equalStringReturned() throws UnsupportedEncodingException { final String str = "qwer"; final String crtEncoding = StandardCharsets.UTF_16LE.displayName(); String result = EncodingUtils.toUTF8(str, crtEncoding); assertEquals(str.charAt(0), result.charAt(0)); assertEquals(str.charAt(1), result.charAt(2)); assertEquals(str.charAt(2), result.charAt(4)); assertEquals(str.charAt(3), result.charAt(6)); }
public static String toUTF8(@NotNull String str, @NotNull String crtEncoding) throws UnsupportedEncodingException { return new String(str.getBytes(crtEncoding), StandardCharsets.UTF_8); }
EncodingUtils { public static String toUTF8(@NotNull String str, @NotNull String crtEncoding) throws UnsupportedEncodingException { return new String(str.getBytes(crtEncoding), StandardCharsets.UTF_8); } }
EncodingUtils { public static String toUTF8(@NotNull String str, @NotNull String crtEncoding) throws UnsupportedEncodingException { return new String(str.getBytes(crtEncoding), StandardCharsets.UTF_8); } private  EncodingUtils(); }
EncodingUtils { public static String toUTF8(@NotNull String str, @NotNull String crtEncoding) throws UnsupportedEncodingException { return new String(str.getBytes(crtEncoding), StandardCharsets.UTF_8); } private  EncodingUtils(); static String discardBOMChar(@NotNull String str); static String toUTF8(@NotNull String str, @NotNull String crtEncoding); static String escapePotentialMaliciousCharsInTxt(@NotNull String str); static String escapePotentialMaliciousCharsInXml(@NotNull String str); }
EncodingUtils { public static String toUTF8(@NotNull String str, @NotNull String crtEncoding) throws UnsupportedEncodingException { return new String(str.getBytes(crtEncoding), StandardCharsets.UTF_8); } private  EncodingUtils(); static String discardBOMChar(@NotNull String str); static String toUTF8(@NotNull String str, @NotNull String crtEncoding); static String escapePotentialMaliciousCharsInTxt(@NotNull String str); static String escapePotentialMaliciousCharsInXml(@NotNull String str);  }