home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
URLDecoder.java
< prev
next >
Wrap
Text File
|
1998-09-22
|
1KB
|
40 lines
package com.symantec.itools.net;
/*
URLDecoder :
Provided for symmetry.
TODO verify for non US char encoding.
*/
public class URLDecoder
{
public static String decode( String s )
{
java.util.StringTokenizer stok = new java.util.StringTokenizer( s, "+%", true );
StringBuffer sb = new StringBuffer();
while( stok.hasMoreTokens() )
{
String s1 = stok.nextToken();
byte[] barr = new byte[ 1 ];
if ( s1.equals( "+" ) )
{
sb.append( ' ' );
}
else if ( s1.equals( "%" ) )
{
s1 = stok.nextToken();
String s2 = s1.substring( 0, 2 );
barr[ 0 ] = Byte.parseByte( s2, 16 );
s2 = new String( barr );
sb.append( s2 );
s1 = s1.substring( 2 );
sb.append( s1 );
}
else
{
sb.append( s1 );
}
}
return sb.toString();
}
}