FileUpload: File name in Japanese characters

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

FileUpload: File name in Japanese characters

hitesh.j

Hi,

I am using FileUpload commons package to upload file. I am saving the file
uploaded by using after appending unique number to file name.
To handle i18n my each jsp contains contentType="text/html; charset=utf-8"
@ page tag.
Whenever user is uploading file with Japanese characters in File name,
file is saved on server with corrupted name (contains characters '?' etc).

Any pointer on this front?

Regards,
Hitesh Chandmal Jodhavat


Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you
Reply | Threaded
Open this post in threaded view
|

Re: FileUpload: File name in Japanese characters

Jason Lea
You will need to set the request encoding before calling FileUpload.

eg  request.setCharacterEncoding("UTF-8")

There may be something in FileUpload where the request encoding can be
set.  But setting the request encoding before FileUpload is given the
request should work.

[hidden email] wrote:

>Hi,
>
>I am using FileUpload commons package to upload file. I am saving the file
>uploaded by using after appending unique number to file name.
>To handle i18n my each jsp contains contentType="text/html; charset=utf-8"
>@ page tag.
>Whenever user is uploading file with Japanese characters in File name,
>file is saved on server with corrupted name (contains characters '?' etc).
>
>Any pointer on this front?
>
>Regards,
>Hitesh Chandmal Jodhavat
>
>
>Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you
>  
>

--
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: FileUpload: File name in Japanese characters

hitesh.j

Hi,

request.setCharacterEncoding("UTF-8") is done before File save.
I printed the file name in log and it is printed properly with Japanese
characters.

Actually I am appending some unique id to File Name and then saving on
disk.
I guess there is problem when I am appending the id to file name.

Is anybody aware of solution to this problem?

Regards,
Hitesh Chandmal Jodhavat




Jason Lea <[hidden email]>
06/07/2005 06:33 PM
Please respond to
"Jakarta Commons Users List" <[hidden email]>


To
Jakarta Commons Users List <[hidden email]>
cc

Subject
Re: FileUpload: File name in Japanese characters






You will need to set the request encoding before calling FileUpload.

eg  request.setCharacterEncoding("UTF-8")

There may be something in FileUpload where the request encoding can be
set.  But setting the request encoding before FileUpload is given the
request should work.

[hidden email] wrote:

>Hi,
>
>I am using FileUpload commons package to upload file. I am saving the
file
>uploaded by using after appending unique number to file name.
>To handle i18n my each jsp contains contentType="text/html;
charset=utf-8"
>@ page tag.
>Whenever user is uploading file with Japanese characters in File name,
>file is saved on server with corrupted name (contains characters '?'
etc).
>
>Any pointer on this front?
>
>Regards,
>Hitesh Chandmal Jodhavat
>
>
>Notice: The information contained in this e-mail message and/or
attachments to it may contain confidential or privileged information.   If
you are not the intended recipient, any dissemination, use, review,
distribution, printing or copying of the information contained in this
e-mail message and/or attachments to it are strictly prohibited.   If you
have received this communication in error, please notify us by reply
e-mail or telephone and immediately and permanently delete the message and
any attachments.  Thank you
>
>

--
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


ForwardSourceID:NT000020D6


Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you
Reply | Threaded
Open this post in threaded view
|

Re: FileUpload: File name in Japanese characters

Jason Lea
Can the file system support japanese characters?

Can you rename a file and cut-and-paste some japanese characters in for
the filename?

[hidden email] wrote:

>Hi,
>
>request.setCharacterEncoding("UTF-8") is done before File save.
>I printed the file name in log and it is printed properly with Japanese
>characters.
>
>Actually I am appending some unique id to File Name and then saving on
>disk.
>I guess there is problem when I am appending the id to file name.
>
>Is anybody aware of solution to this problem?
>
>Regards,
>Hitesh Chandmal Jodhavat
>  
>

--
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: FileUpload: File name in Japanese characters

hitesh.j

Hi Jason,

The file system supports Japanese characters. I wrote a small java program
which creating file with file name containing Japanese characters.
In my web application I printed the File name in log and it is showing in
Japanese.
But when I am saving file on Disk using FileItem.write() method it is
saving file with corrupted name.
Even I tried to save file using OutputStream but that also saved with
corrupted name.

I guess the problem is with FileName.
As I said before that request.setCharacterEncoding("UTF-8") is done before
handling request data.
I am creating File object passing the FileName and FileName may be in
"utf-8" format. I am not sure whether File() support String in utf-8
format. But normal String operation (concatenation etc) are working
properly and printed properly in log files.

Even I tried following

                                                byte[] b =
fileName.getBytes("utf-8");
                                                String fileName1 = new
String(b,"SJIS");
                                                System.out.println(
"fileName1 = " + fileName1);

SJIS is character format supported by Japanese OS. But this showing
corrupted string even in log file.

Any pointer to this problem?

Regards,
Hitesh Chandmal Jodhavat




Jason Lea <[hidden email]>
06/08/2005 01:15 PM
Please respond to
"Jakarta Commons Users List" <[hidden email]>


To
Jakarta Commons Users List <[hidden email]>
cc

Subject
Re: FileUpload: File name in Japanese characters






Can the file system support japanese characters?

Can you rename a file and cut-and-paste some japanese characters in for
the filename?

[hidden email] wrote:

>Hi,
>
>request.setCharacterEncoding("UTF-8") is done before File save.
>I printed the file name in log and it is printed properly with Japanese
>characters.
>
>Actually I am appending some unique id to File Name and then saving on
>disk.
>I guess there is problem when I am appending the id to file name.
>
>Is anybody aware of solution to this problem?
>
>Regards,
>Hitesh Chandmal Jodhavat
>
>

--
Jason Lea



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


ForwardSourceID:NT0000213A


Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you
Reply | Threaded
Open this post in threaded view
|

Re: FileUpload: File name in Japanese characters

Ronald Klop-2
Try FileUpload.setHeaderEncoding(...).

See fileupload javadoc:  
http://jakarta.apache.org/commons/fileupload/apidocs/index.html

setHeaderEncoding

public void setHeaderEncoding(java.lang.String encoding)
Specifies the character encoding to be used when reading the headers of  
individual parts. When not specified, or null, the platform default  
encoding is used.

Parameters:
encoding - The encoding used to read part headers.


The filename is in the headers.

Ronald.

On Fri, 10 Jun 2005 08:26:34 +0200, <[hidden email]> wrote:

>
> Hi Jason,
>
> The file system supports Japanese characters. I wrote a small java  
> program
> which creating file with file name containing Japanese characters.
> In my web application I printed the File name in log and it is showing in
> Japanese.
> But when I am saving file on Disk using FileItem.write() method it is
> saving file with corrupted name.
> Even I tried to save file using OutputStream but that also saved with
> corrupted name.
>
> I guess the problem is with FileName.
> As I said before that request.setCharacterEncoding("UTF-8") is done  
> before
> handling request data.
> I am creating File object passing the FileName and FileName may be in
> "utf-8" format. I am not sure whether File() support String in utf-8
> format. But normal String operation (concatenation etc) are working
> properly and printed properly in log files.
>
> Even I tried following
>
>                                                 byte[] b =
> fileName.getBytes("utf-8");
>                                                 String fileName1 = new
> String(b,"SJIS");
>                                                 System.out.println(
> "fileName1 = " + fileName1);
>
> SJIS is character format supported by Japanese OS. But this showing
> corrupted string even in log file.
>
> Any pointer to this problem?
>
> Regards,
> Hitesh Chandmal Jodhavat
>
>
>
>
> Jason Lea <[hidden email]>
> 06/08/2005 01:15 PM
> Please respond to
> "Jakarta Commons Users List" <[hidden email]>
>
>
> To
> Jakarta Commons Users List <[hidden email]>
> cc
>
> Subject
> Re: FileUpload: File name in Japanese characters
>
>
>
>
>
>
> Can the file system support japanese characters?
>
> Can you rename a file and cut-and-paste some japanese characters in for
> the filename?
>
> [hidden email] wrote:
>
>> Hi,
>>
>> request.setCharacterEncoding("UTF-8") is done before File save.
>> I printed the file name in log and it is printed properly with Japanese
>> characters.
>>
>> Actually I am appending some unique id to File Name and then saving on
>> disk.
>> I guess there is problem when I am appending the id to file name.
>>
>> Is anybody aware of solution to this problem?
>>
>> Regards,
>> Hitesh Chandmal Jodhavat
>>
>>
>



--
  Ronald Klop
  Amsterdam, The Netherlands

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: FileUpload: File name in Japanese characters

Martin Cooper
In reply to this post by hitesh.j
On 6/9/05, [hidden email] <[hidden email]> wrote:

>
> Hi Jason,
>
> The file system supports Japanese characters. I wrote a small java program
> which creating file with file name containing Japanese characters.
> In my web application I printed the File name in log and it is showing in
> Japanese.
> But when I am saving file on Disk using FileItem.write() method it is
> saving file with corrupted name.
> Even I tried to save file using OutputStream but that also saved with
> corrupted name.
>
> I guess the problem is with FileName.
> As I said before that request.setCharacterEncoding("UTF-8") is done before
> handling request data.
> I am creating File object passing the FileName and FileName may be in
> "utf-8" format. I am not sure whether File() support String in utf-8
> format. But normal String operation (concatenation etc) are working
> properly and printed properly in log files.
>
> Even I tried following
>
>                                                 byte[] b =
> fileName.getBytes("utf-8");
>                                                 String fileName1 = new
> String(b,"SJIS");
>                                                 System.out.println(
> "fileName1 = " + fileName1);
>
> SJIS is character format supported by Japanese OS. But this showing
> corrupted string even in log file.

Well, yes, of course this will fail. You're asking for the bytes
encoded as UTF-8 and then constructing a string by specifying that the
encoding is SJIS, but the encoding of the bytes you're giving it is
UTF-8, because that's what you asked for when you retrieved them in
the first place.

Strings in Java are Unicode. Encodings such as UTF-8 and SJIS have
nothing to do with the String itself. They relate to how it is
serialised into a sequence of bytes, or deserialised from a sequence
of bytes.

Do you actually know what encoding the browser is sending you? Did you
tell it that you wanted it to send you UTF-8? Did you include the
necessary <meta http-equiv> element in your page?

--
Martin Cooper


> Any pointer to this problem?
>
> Regards,
> Hitesh Chandmal Jodhavat
>
>
>
>
> Jason Lea <[hidden email]>
> 06/08/2005 01:15 PM
> Please respond to
> "Jakarta Commons Users List" <[hidden email]>
>
>
> To
> Jakarta Commons Users List <[hidden email]>
> cc
>
> Subject
> Re: FileUpload: File name in Japanese characters
>
>
>
>
>
>
> Can the file system support japanese characters?
>
> Can you rename a file and cut-and-paste some japanese characters in for
> the filename?
>
> [hidden email] wrote:
>
> >Hi,
> >
> >request.setCharacterEncoding("UTF-8") is done before File save.
> >I printed the file name in log and it is printed properly with Japanese
> >characters.
> >
> >Actually I am appending some unique id to File Name and then saving on
> >disk.
> >I guess there is problem when I am appending the id to file name.
> >
> >Is anybody aware of solution to this problem?
> >
> >Regards,
> >Hitesh Chandmal Jodhavat
> >
> >
>
> --
> Jason Lea
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ForwardSourceID:NT0000213A
>
>
> Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]