M
maxwelton
This problem concerns values returned from a FileDialog.getDirectory
that appear to be ASCII encoded. I need these to be in UTF-16.
This problem only seems to occur using the Apple version of the applet.
My java version is 1.4.2_03
The problem is not there if I type the name of the directory but only
if
I select it.
If I set the Mac in spanish and select a directory in the file save
dialog with an accented character > 0x7f, the FileDialog is giving
me 2 characters instead of one and it isn't UTF-8 or UTF-16.
For example if the directory name has the character: é , the bytes
I am getting are 0x65 and "unreadable" which is represented by ? or
0x3f..
When I use getBytes(UTF-16) encoding I can read the second one.
They are 0065 (this is e) and 0301 (this is ' ). It appears to make the
one character into two. What I want is 00E9 the UTF-16 value.
Does anyone know what is needed to fix this problem? The file
actually gets stored in the directory but It is preventing my
launch from working.
Here is a snippet::
String fileDirectory;
Frame theFrame = new Frame();
FileDialog myDialog = new FileDialog(theFrame, "Dialog Box",
FileDialog.SAVE);
myDialog.show();
if (myDialog.getDirectory() != NULL){
fileDirectory = myDialog.getDirectory();
// debug section //
byte[] values = fileDirectory.getBytes("UTF-16")
String hex = "";
String tmp = "";
for(int i = 0; i < values.length; i++){
tmp = Integer.toHexString(values);
if (tmp.length() == 1){
hex += '0'+tmp;
}else{
hex += tmp;
}
}
System.out.println("Hex values: "+hex);
}
that appear to be ASCII encoded. I need these to be in UTF-16.
This problem only seems to occur using the Apple version of the applet.
My java version is 1.4.2_03
The problem is not there if I type the name of the directory but only
if
I select it.
If I set the Mac in spanish and select a directory in the file save
dialog with an accented character > 0x7f, the FileDialog is giving
me 2 characters instead of one and it isn't UTF-8 or UTF-16.
For example if the directory name has the character: é , the bytes
I am getting are 0x65 and "unreadable" which is represented by ? or
0x3f..
When I use getBytes(UTF-16) encoding I can read the second one.
They are 0065 (this is e) and 0301 (this is ' ). It appears to make the
one character into two. What I want is 00E9 the UTF-16 value.
Does anyone know what is needed to fix this problem? The file
actually gets stored in the directory but It is preventing my
launch from working.
Here is a snippet::
String fileDirectory;
Frame theFrame = new Frame();
FileDialog myDialog = new FileDialog(theFrame, "Dialog Box",
FileDialog.SAVE);
myDialog.show();
if (myDialog.getDirectory() != NULL){
fileDirectory = myDialog.getDirectory();
// debug section //
byte[] values = fileDirectory.getBytes("UTF-16")
String hex = "";
String tmp = "";
for(int i = 0; i < values.length; i++){
tmp = Integer.toHexString(values);
if (tmp.length() == 1){
hex += '0'+tmp;
}else{
hex += tmp;
}
}
System.out.println("Hex values: "+hex);
}