Java Utililty Methods String Decode by Charset

List of utility methods to do String Decode by Charset

Description

The list of methods to do String Decode by Charset are organized into topic(s).

Method

Stringdecode(final String str, final Charset charset)
decode
try {
    return URLDecoder.decode(str, charset.name());
} catch (UnsupportedEncodingException ex) {
    throw new AssertionError(charset.name() + " not supported");
Stringdecode(String s, Charset encoding)
Decodes an octet according to RFC 2396.
if (s == null || s.isEmpty()) {
    return null;
StringBuilder sb = new StringBuilder();
boolean fragment = false;
for (int i = 0; i < s.length(); i++) {
    char ch = s.charAt(i);
    switch (ch) {
...
Stringdecode(String url, Charset charset)
decode
try {
    return URLDecoder.decode(url, charset.name());
} catch (UnsupportedEncodingException e) {
    throw new RuntimeException("Unable to encode using charset");
Stringdecode(String value, Charset charset)
Uses URLDecoder to decode a application/x-www-form-urlencoded string, using the given Charset.
try {
    return URLDecoder.decode(value, charset.name());
} catch (UnsupportedEncodingException ex) {
    throw new IllegalArgumentException("Characterset is not supported.");
Stringdecode(String value, Charset charset)
Uri Decode the value.
try {
    return URLDecoder.decode(value, charset.name());
} catch (UnsupportedEncodingException uee) {
    return value;
StringdecodeCharset(String value, String charset)
decode Charset
try {
    Charset set = Charset.forName(charset);
    return set.decode(ByteBuffer.wrap(value.getBytes())).toString();
} catch (Exception ex) {
    return null;
StringdecodeComponent(final String s, final Charset charset)
Decodes a bit of an URL encoded by a browser.
if (s == null) {
    return "";
final int size = s.length();
boolean modified = false;
for (int i = 0; i < size; i++) {
    final char c = s.charAt(i);
    switch (c) {
...
StringdecodeFormFields(final String content, final Charset charset)
decode Form Fields
if (content == null) {
    return null;
return urlDecode(content, charset != null ? charset : Charset.forName("UTF-8"), true);
StringdecodeURL(@Nullable String str, Charset charSet)
Decodes a application/x-www-form-urlencoded string using a specific encoding scheme.
boolean needToChange = false;
int numChars = str.length();
StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars);
int i = 0;
char c;
byte[] bytes = null;
while (i < numChars) {
    c = str.charAt(i);
...
StringdecodeWithDefaultCharSet(String urlToDecode)
decode With Default Char Set
try {
    return URLDecoder.decode(urlToDecode, Charset.defaultCharset().name());
} catch (UnsupportedEncodingException e) {
    return urlToDecode;