[sclug] URL encoding/decoding question

pieter claassen pieter at claassen.co.uk
Mon Feb 20 19:15:41 UTC 2006


hi Will,

Ok, ran your code and the letter A is encoded as (wait for it)

41

The string € is decoded as

26
65
75
72
6f
3b

I am flipped because A in UTF-8 should decode to 65 (not to say why the
€ doesn't make any sense)

Any ideas?

I assume that & 0xFF is to convert UFT-8 to UTF-16 by masking out the
higher order bits?

Pieter





On Mon, 2006-02-20 at 18:39 +0000, Will Dickson wrote:
> pieter claassen wrote:
> > Ok, looks like mozilla is broken in regards to this matter.
> > 
> > So, I thought this should work to intercept all inserts into the db and
> > just convert them back to something civil?
> > 
> > 	static public String decode (String data){
> > 		data.replace(String.valueOf('\u20AC'),"€");
> > 		return data;
> > 	}
> > However, no luck.
> > 
> > My question. How do I print the "data" string in the above code in UTF
> > format so that I can see what is being submitted to the DB?
> 
> Something like:
> 
> byte[] wad = data.getBytes("UTF-8");
> for(int i=0; i<wad.length; i++)
> 	System.out.println(Integer.toHexString( (wad[i] & 0xFF) ));
> 
> might do it.
> 
> 
> Will.




More information about the Sclug mailing list