Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4025732

URLEncoder.encode() doesn't work with non-ASCII characters

XMLWordPrintable

    • 1.1fcs
    • generic, sparc
    • generic, solaris_2.5
    • Not verified

       
      masayoshi.okutsu@Eng 1997-01-14
      URLEncoder.encode() doesn't support non-ASCII Unicode characters. The
      expected behavior is to convert Unicode characters to external encoding
      (default), then to URL encode.

      The following test program outputs (inclusing EUCJIS characters):

           ã³“›©ý
           ã³“›©ý
           %e5%2c%9e
           %e5%2c%9e

      but expected:

           %c6%fc%cb%dc%b8%ec

      for the two bottom lines.

      import java.net.*;
      public class URLEncoder_test {
         public static void main(String[] args) {
            System.out.println("㳓›©ý") ;
            System.out.println("\u65e5\u672c\u8a9e") ;
            System.out.println(URLEncoder.encode("㳓›©ý")) ;
            System.out.println(URLEncoder.encode("\u65e5\u672c\u8a9e")) ;
         }
      }

            nishimur Naoyuki Ishimura (Inactive)
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: