commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikola Petrović" <>
Subject problems with base64 and ascii and php
Date Thu, 28 Aug 2008 22:39:17 GMT
Hello all,
I have a problem with base64 codec and encoding ascii characters. Here`s the
int ok=0, bad=0;
                for(int i=128; i<256; i++){
                        char c = (char)i;
                        str = "" + c;
                        String enc = new
                        String dec = new
                        if(str.equals(dec)) ok++;
                        else bad++;
                System.out.println("ok: " + ok);
                System.out.println("bad: " + bad);

I get this:
ok: 80
bad: 48

So, simple encoding and decoding of ascii chars > 128 doesn`t work for me.
Is there some explanation?
I tried this on os x, java5 and java6, doesn`t work, and on java6 on solaris
pc it does. That confuses me totally :)

The other part of the problem is probably linked to this one. I`m trying to
encode a string in my java code, and decode it in some php code that I use.
Is that possible? I guess since base64 is a standard it should work, and yet
it doesn`t on os x, nor on solaris :(   Maybe it is linked somehow to the
ascii char problem?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message