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

NetworkInterface#getDisplayName() method returns wrong encoding for Japanese OS

XMLWordPrintable

    • b69
    • x86
    • windows_xp
    • Not verified

        FULL PRODUCT VERSION :
        java version "1.5.0_09"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
        Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode)

        and

        java version "1.6.0"
        Java(TM) SE Runtime Environment (build 1.6.0-b105)
        Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        Japanese Microsoft Windows XP [Version 5.1.2600]

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Intel(R) PRO/1000 MT Network Connection - Packet Scheduler Miniport

        A DESCRIPTION OF THE PROBLEM :
        Under Japanese Windows environment, NetworkInterface#getDisplayName() method returns wrong encoded string of "Packet Scheduler Miniport" in Japanese. So, I can not read it.


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run following class under Japanese Windows
        //exp: The translation for "Packet Scheduler Miniport" is displayed at "//act:" line in Japanese.
        //act: Intel(R) PRO/1000 MT Network Connection - ?p?P?b?g ?X?P?W???[?? ?~?j?|?[?g


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        //exp: The translation for "Packet Scheduler Miniport" is displayed at "//act:" line in Japanese.

        ACTUAL -
        The following wrong encoded characters ate displayed for the "Packet Scheduler Miniport" in Japanese.
        //act: Intel(R) PRO/1000 MT Network Connection - ?p?P?b?g ?X?P?W???[?? ?~?j?|?[?g


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        /*
        Run following class under Japanese Windows
        //exp: The translation for "Packet Scheduler Miniport" is displayed at "//act:" line in Japanese.
        //act: Intel(R) PRO/1000 MT Network Connection - ?p?P?b?g ?X?P?W???[?? ?~?j?|?[?g

        */
        package displaynametest;
        import java.net.*;
        import java.util.Enumeration;
        import java.io.*;
        public class Main {
        public static void main(String[] args) {
        try {
        NetworkInterface aninterface = null;
        for (Enumeration <NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) {
        aninterface = e.nextElement();
        String displayName = aninterface.getDisplayName();
        System.out.println( "//act: " + displayName);
        System.out.println( "//exp: " + new String(displayName.getBytes("ISO-8859-1"),"MS932"));
        }
        } catch (SocketException e) {
        e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        }
        }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Convert the return string like following in user application.
        new String(aninterface.getDisplayName().getBytes("ISO-8859-1"),"MS932"))

              chegar Chris Hegarty
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: