Netbeans Ascii unicode char not working base64 encoding decoding

I’m customized base64 algorithm and it working properly in cmd.
In this algorithm changed some characters and other stuff for research purpose.

I was find original base64 algorithm in following link
https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64

so new customize code is working properly in command prompt but
when start code in netbeans GUI it throw error because of unicode characters.

Why ascii unicode is not working in netbeans but working in terminal?
How to use that ascii code value in netbeans GUI?

Following is my base code after some modify.

class CustomeBase64Encode {     //Old Char     //private final static String base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";     //New Char     private final static String base64chars = "☻♥♦♣♠•◘○♂☼►♫☼‼_MyCustomeCharacters+/";      public static String encode(String s) {      // the result/encoded string, the padding string, and the pad count     String r = "", p = "";     int c = s.length() % 3;      // add a right zero pad to make this string a multiple of 3 characters     if (c > 0) {         for (; c < 3; c++) {         p += "=";         s += "\0";         }     }      // increment over the length of the string, three characters at a time     for (c = 0; c < s.length(); c += 3) {          // we add newlines after every 76 output characters, according to         // the MIME specs         if (c > 0 && (c / 3 * 4) % 76 == 0)         r += "\r\n";          // these three 8-bit (ASCII) characters become one 24-bit number         int n = (s.charAt(c) << 16) + (s.charAt(c + 1) << 8)             + (s.charAt(c + 2));          // this 24-bit number gets separated into four 6-bit numbers         int n1 = (n >> 18) & 63, n2 = (n >> 12) & 63, n3 = (n >> 6) & 63, n4 = n & 63;          // those four 6-bit numbers are used as indices into the base64         // character list         r += "" + base64chars.charAt(n1) + base64chars.charAt(n2)             + base64chars.charAt(n3) + base64chars.charAt(n4);     }      return r.substring(0, r.length() - p.length()) + p;     }  public static String decode(String s) {  s = s.replaceAll("[^" + chars64 + "=]", "");  String p = (s.charAt(s.length() - 1) == '=' ?      (s.charAt(s.length() - 2) == '=' ? "☻☻" : "☻") : ""); String r = ""; s = s.substring(0, s.length() - p.length()) + p;  for (int c = 0; c < s.length(); c += 4) {     int n = (chars64.indexOf(s.charAt(c)) << 18)         + (chars64.indexOf(s.charAt(c + 1)) << 12)         + (chars64.indexOf(s.charAt(c + 2)) << 6)         + chars64.indexOf(s.charAt(c + 3));      r += "" + (char) ((n >>> 16) & 0xFF) + (char) ((n >>> 8) & 0xFF)         + (char) (n & 0xFF); }  // remove any zero pad that was added to make this a multiple of 24 bits return r.substring(0, r.length() - p.length()); } } 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.