List of utility methods to do UTF8
byte[] | decodePayloadFromUtf8(String utf8string) Helper method that takes an UTF-8 string and returns its byte representation. return utf8string.getBytes(UTF8_CHARSET);
|
String | decodeUTF8(byte[] bytes) decode UTF try { return new String(bytes, UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); |
String | decodeUtf8(String url) decode Utf try { return URLDecoder.decode(url, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unable to encode using charset"); |
String | decUTF8(String s) dec UTF try { return URLDecoder.decode(s, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("Standard encoding UTF-8 is missing"); |
void | dumpStringArray(Path outputFilePath, String[] stringArray) dump String Array try (BufferedWriter os = Files.newBufferedWriter(outputFilePath, Charset.forName("UTF-8"))) { for (int i = 0; i < stringArray.length; i++) { os.write(stringArray[i]); os.newLine(); |
void | dumpUtf8ToFile(List Dump UTF-8 records to the given file using the specified delimiter (or newline if null). byte[] delimiterBytes = (delimiter != null ? delimiter : "\n").getBytes(StandardCharsets.UTF_8); byte[] d = new byte[] {}; try (FileOutputStream output = new FileOutputStream(file)) { for (String line : records) { output.write(d); d = delimiterBytes; output.write(line.getBytes(StandardCharsets.UTF_8)); |
String | fromUTF8(byte[] ba) from UTF return new String(ba, StandardCharsets.UTF_8); |
String | fromUTF8(byte[] bytes) from UTF return new String(bytes, UTF8); |
String | fromUTF8(byte[] bytes) Decodes UTF-8 bytes to String. return fromUTF8(bytes, 0, bytes.length);
|
byte[] | generateRawUTF8Bytes(final String string) Generates a byte array that is populated with the UTF-8 encoding of the provided String. return string.getBytes(StandardCharsets.UTF_8);
|