mirror of git://gcc.gnu.org/git/gcc.git
URLEncoder.java (encode(String)): Use platform default encoding.
* java/net/URLEncoder.java (encode(String)): Use platform default encoding. (encode(String,String)): Convert to 2-digit upper-case hex number. (hex): New field. From-SVN: r69678
This commit is contained in:
parent
3988d17951
commit
c39603389e
|
@ -1,3 +1,11 @@
|
||||||
|
2003-07-22 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* java/net/URLEncoder.java (encode(String)): Use platform default
|
||||||
|
encoding.
|
||||||
|
(encode(String,String)): Convert to 2-digit upper-case hex
|
||||||
|
number.
|
||||||
|
(hex): New field.
|
||||||
|
|
||||||
2003-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
|
2003-07-21 Thomas Fitzsimmons <fitzsim@redhat.com>
|
||||||
|
|
||||||
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
|
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* URLEncoder.java -- Class to convert strings to a properly encoded URL
|
/* URLEncoder.java -- Class to convert strings to a properly encoded URL
|
||||||
Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
|
Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of GNU Classpath.
|
This file is part of GNU Classpath.
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ import java.io.UnsupportedEncodingException;
|
||||||
* US alphabet remain as is, the space character (' ') is replaced with
|
* US alphabet remain as is, the space character (' ') is replaced with
|
||||||
* '+' sign, and all other characters are converted to a "%XX" format
|
* '+' sign, and all other characters are converted to a "%XX" format
|
||||||
* where XX is the hexadecimal representation of that character in a
|
* where XX is the hexadecimal representation of that character in a
|
||||||
* certain encoding (by default "UTF-8").
|
* certain encoding (by default, the platform encoding, though the
|
||||||
|
* standard is "UTF-8").
|
||||||
* <p>
|
* <p>
|
||||||
* This method is very useful for encoding strings to be sent to CGI scripts
|
* This method is very useful for encoding strings to be sent to CGI scripts
|
||||||
*
|
*
|
||||||
|
@ -65,8 +66,9 @@ public class URLEncoder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This method translates the passed in string into x-www-form-urlencoded
|
* This method translates the passed in string into x-www-form-urlencoded
|
||||||
* format using the standard "UTF-8" character encoding to hex-encode the
|
* format using the default encoding. The standard encoding is
|
||||||
* unsafe characters.
|
* "UTF-8", and the two-argument form of this method should be used
|
||||||
|
* instead.
|
||||||
*
|
*
|
||||||
* @param s The String to convert
|
* @param s The String to convert
|
||||||
*
|
*
|
||||||
|
@ -78,11 +80,13 @@ public class URLEncoder
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return encode(s, "UTF-8");
|
// We default to 8859_1 for compatibility with the same
|
||||||
|
// default elsewhere in the library.
|
||||||
|
return encode(s, System.getProperty("file.encoding", "8859_1"));
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException uee)
|
catch (UnsupportedEncodingException uee)
|
||||||
{
|
{
|
||||||
// Should never happen since UTF-8 should always be supported
|
// Should never happen since default should always be supported
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +143,9 @@ public class URLEncoder
|
||||||
for (int j = 0; j < bytes.length; j++)
|
for (int j = 0; j < bytes.length; j++)
|
||||||
{
|
{
|
||||||
result.append('%');
|
result.append('%');
|
||||||
result.append(Integer.toHexString(((int) bytes[j]) & 0xFF));
|
int val = bytes[j];
|
||||||
|
result.append(hex.charAt((val & 0xf0) >> 4));
|
||||||
|
result.append(hex.charAt(val & 0x0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start = i;
|
start = i;
|
||||||
|
@ -166,4 +172,11 @@ public class URLEncoder
|
||||||
*/
|
*/
|
||||||
private URLEncoder() { }
|
private URLEncoder() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to convert to hex. We don't use Integer.toHexString, since
|
||||||
|
* it converts to lower case (and the Sun docs pretty clearly
|
||||||
|
* specify upper case here), and because it doesn't provide a
|
||||||
|
* leading 0.
|
||||||
|
*/
|
||||||
|
private static final String hex = "0123456789ABCDEF";
|
||||||
} // class URLEncoder
|
} // class URLEncoder
|
||||||
|
|
Loading…
Reference in New Issue