Source:
private static String convertToExtended(String contents) { int length = contents.length(); StringBuilder extendedContent = new StringBuilder(length * 2); for (int i = 0; i < length; i++) { char character = contents.charAt(i); if (character == 0) { extendedContent.append("bU"); } else if (character <= 26) { extendedContent.append('a'); extendedContent.append((char) ('A' + character - 1)); } else if (character <= 31) { extendedContent.append('b'); extendedContent.append((char) ('A' + character - 27)); } else if (character == ' ' || character == '$' || character == '%' || character == '+') { extendedContent.append(character); } else if (character <= ',') { extendedContent.append('c'); extendedContent.append((char) ('A' + character - '!')); } else if (character <= '9') { extendedContent.append(character); } else if (character == ':') { extendedContent.append("cZ"); } else if (character <= '?') { extendedContent.append('b'); extendedContent.append((char) ('F' + character - ';')); } else if (character == '@') { extendedContent.append("bV"); } else if (character <= 'Z') { extendedContent.append(character); } else if (character <= '_') { extendedContent.append('b'); extendedContent.append((char) ('K' + character - '[')); } else if (character == '`') { extendedContent.append("bW"); } else if (character <= 'z') { extendedContent.append('d'); extendedContent.append((char) ('A' + character - 'a')); } else if (character <= 127) { extendedContent.append('b'); extendedContent.append((char) ('P' + character - '{')); } else { throw new IllegalArgumentException( "Requested content contains a non-encodable character: '" + character + "'"); } } return extendedContent.toString(); }

Target:
static String convertToExtended(String contents) { int length = contents.length(); StringBuilder extendedContent = new StringBuilder(length * 2); for (int i = 0; i < length; i++) { char character = contents.charAt(i); if (character == 0) { extendedContent.append("bU"); } else if (character <= 26) { extendedContent.append('a'); extendedContent.append((char) ('A' + character - 1)); } else if (character <= 31) { extendedContent.append('b'); extendedContent.append((char) ('A' + character - 27)); } else if (character == ' ' || character == '$' || character == '%' || character == '+') { extendedContent.append(character); } else if (character <= ',') { extendedContent.append('c'); extendedContent.append((char) ('A' + character - '!')); } else if (character <= '9') { extendedContent.append(character); } else if (character == ':') { extendedContent.append("cZ"); } else if (character <= '?') { extendedContent.append('b'); extendedContent.append((char) ('F' + character - ';')); } else if (character == '@') { extendedContent.append("bV"); } else if (character <= 'Z') { extendedContent.append(character); } else if (character <= '_') { extendedContent.append('b'); extendedContent.append((char) ('K' + character - '[')); } else if (character == '`') { extendedContent.append("bW"); } else if (character <= 'z') { extendedContent.append('d'); extendedContent.append((char) ('A' + character - 'a')); } else if (character <= 127) { extendedContent.append('b'); extendedContent.append((char) ('P' + character - '{')); } else { throw new IllegalArgumentException( "Requested content contains a non-encodable character: '" + character + "'"); } } return extendedContent.toString(); }