In my Application i am reading registry to get all TimeZone names. It is working fine with native english OS machine.
But for chinese native os it is showing "????????".
I am using WinRegistry.java, the common file available to read registry in java.
Below is the method that reads bytes from registry, but that bytes contains junk characters only.
private static String readString(Preferences root, int hkey, String key, String value)
throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException
{
int[] handles = (int[]) regOpenKey.invoke(root, new Object[] {
new Integer(hkey), toCstr(key), new Integer(KEY_READ) });
if (handles[1] != REG_SUCCESS) {
return null;
}
byte[] valb = (byte[]) regQueryValueEx.invoke(root, new Object[] {
new Integer(handles[0]), toCstr(value) });
regCloseKey.invoke(root, new Object[] { new Integer(handles[0]) });
return (valb != null ? new String(valb).trim() : null);
}
In valb[] byte array i am getting the junk characters, so whatever encoding i use to convert that byte array to string, i am getting junk characters only. Can any one suggest me, what changes in this method will make it work fine??