Java applet - it is not possible to change the default encoding of the platform for some other

I ran into an encoding problem (I think) when I try to upload a file with a file name that has swedish charachters Ӧ Ӓ å. Applet works fine when I upload a file on Windows, but not on Mac OS.

The file name is confused when printing on the server side, which is the Domino server, and shows the fields on the Mac, but when I set the encoding to UTF-8 on new String(filename.getBytes("utf-8")), it shows ?on both Win and Win Mac.

UPDATED:

The following are snippets of code:

Setting request and publishing parameters

...
request.setParameter("Name", tmpAtt.getFileName());
...

HttpURLConnection connection ...
connection.setRequestProperty("Content-Type", "multipart/form-data; charset=UTF-8; boundary=" + boundary);

if (os == null) os = connection.getOutputStream();

Settings for File Name and Inputstream

request.setParameter(fileUploadFieldName, tmpAtt.getFilePath(), fi);

public void setParameter(String name, String filename, InputStream is) throws IOException {
    boundary();
    writeName(name);
    write("; charset=utf-8; filename=\"");
    write(filename);
    write('"');
    newline();
    write("Content-Type:");
    String type = connection.guessContentTypeFromName(filename);
    if (type == null) type = "application/octet-stream";
    writeln(type);
    newline();
    pipe(is, os);
    newline();
}

At the end of the message to the server

public InputStream post() throws IOException {
    boundary();
    writeln("--");
    printOS(os);
    os.close();
    InputStream iis = connection.getInputStream();
    printIS(iis);
    return iis;
}

Getting this output by writing bytes to an OutputStream to send a request. And the name looks good to me.

------------------------------hxre3intl6yy-17eufpccwtxc89pbvyg0iwe3i
Content-Disposition: form-data; name="Name

Räpörå.log
------------------------------hxre3intl6yy-17eufpccwtxc89pbvyg0iwe3i
Content-Disposition: form-data; name="Name2


------------------------------hxre3intl6yy-17eufpccwtxc89pbvyg0iwe3i
Content-Disposition: form-data; name="APPROVALSTATUS

What could be the problem.

.

+3
2

Java UTF-16, , " " .

. , - , , , Java .

API- String, , filename, , , , , " " Java.

eclipse , .

+2

ISO-8859-1.

write("Content-Type:"); :

1. write(String s){
2. os.write(s.getBytes());
3. }

os.write(s.getBytes("ISO-8859-1"))

UTF-8, , ???

- MacRoman, ISO-8859-1 ( ) request.setParameter("Name", new String(tmpAtt.getFileName().getBytes("ISO-8859-1")));, Name.

, UTF-8 - ???

0

All Articles