Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Java applet file dialog encoding

Reply
Thread Tools

Java applet file dialog encoding

 
 
maxwelton@my-deja.com
Guest
Posts: n/a
 
      02-09-2006
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[i]);
if (tmp.length() == 1){
hex += '0'+tmp;
}else{
hex += tmp;
}
}
System.out.println("Hex values: "+hex);
}

 
Reply With Quote
 
 
 
 
maxwelton@my-deja.com
Guest
Posts: n/a
 
      03-02-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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[i]);
> if (tmp.length() == 1){
> hex += '0'+tmp;
> }else{
> hex += tmp;
> }
> }
> System.out.println("Hex values: "+hex);
> }



Anybody?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Text File Encoding and converting to Perls internal UTF-8 encoding sln@netherlands.com Perl Misc 2 04-17-2009 11:22 PM
confussed about showStatus in java.applet.Applet yawnmoth Java 1 08-15-2006 05:44 AM
Java Applet loading in Applet Viewer but not in HTML page Archana Java 1 10-24-2004 11:41 PM
Java applet failed when I try to load the avi file in my java applet Krista Java 3 09-15-2004 02:53 AM
Re: play wave files using java.applet.Applet webster Java 0 07-20-2003 01:51 PM



Advertisments