0

I am trying to upload a file using form and this file contain EURO symbol (€). I have already set charset and encoding UTF-8 in form but when i am reading this file i am getting '?' symbol instead of '€' symbol.

I have gone through the charset details and found that '€' is not supported by UTF-8 but it's the default encoding for LINUX.

Could you please suggest how can i resolve this issue. This file upload functionality is used by users so i can't force to use UTF-8 encoded file.

Thanks in advance.

Ankit16
  • 13
  • 1
  • 4
  • Files uploaded by HTML forms are uploaded as-is as binary data, so character encodings do not apply. If you are writing a server that receives the binary file data as textual data with character encodings applied to it, then your server is implemented wrong. Please show your actual code. Oh, and your claim that "*'€' is not supported by UTF-8*" is completely wrong, since UTF-8 supports the *entire* Unicode repertoire of codepoints. – Remy Lebeau Sep 27 '16 at 04:39
  • Hi Remy, Thanks for your comment... Functionality is to upload the file in DB as a CLOB and then read the CLOB value to populate VO. DB charset parameters are NLS_CHARACTERSET= WE8ISO8859P15 NLS_NCHAR_CHARACTERSET=AL16UTF16 For Example: String d= "T,€,C,10,13/07/2016,PerfTest1"; byte[] bytes= d.getBytes(Charset.forName("UTF-8")); String s= new String(bytes,Charset.forName("UTF-8")); System.out.println(s); Error: error: unmappable character for encoding ASCII String d= "T,???,C,10,13/07/2016,PerfTest1"; – Ankit16 Sep 27 '16 at 06:13
  • binary data should be stored in a BLOB, not a CLOB. But, if your users will only ever upload text files, and you want to store them as textual data in the DB, you would still have to detect and convert the files from their actual source encoding to your DB's encoding. However, your DB is using ISO-8859-1, which does not support `€`. UTF-8 does. Change your DB encoding. In any case, there is no possible way your example code can cause that error when encoding/decoding the bytes back and forth, so the error has to be coming from `println()` if it encodes to ASCII for display on the terminal – Remy Lebeau Sep 27 '16 at 15:30

0 Answers0