United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6512101 NetworkInterface#getDisplayName() method returns wrong encoding for Japanese OS
JDK-6512101 : NetworkInterface#getDisplayName() method returns wrong encoding for Japanese OS

Details
Type:
Bug
Submit Date:
2007-01-11
Status:
Closed
Updated Date:
2013-06-26
Project Name:
JDK
Resolved Date:
2012-12-11
Component:
core-libs
OS:
windows_xp
Sub-Component:
java.net
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Backport:

Sub Tasks

Description
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"))

                                    

Comments
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/883feced1cdd
User:  luchsh
Date:  2012-12-11 02:43:24 +0000

                                     
2012-12-11
Added 'noreg-hard' label. Requires Windows machine configured with network interfaces that contain Japanese (or other) characters.
                                     
2012-12-11
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/883feced1cdd
User:  lana
Date:  2012-12-18 21:18:52 +0000

                                     
2012-12-18



Hardware and Software, Engineered to Work Together