1

I've a Java agent (running on Linux server) that manage document attachments, but something wrong with accented chars in their names (ò,è,ù ecc..).

I wrote this code to display the charset used:

OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream());
String enc = writer.getEncoding();
System.out.println("CHARSET: " + enc);

This display

CHARSET: ASCII

In a server where everything works fine, same line print:

CHARSET: UTF8

Servers have same configuration (works with "Internet sites", where "Use UTF-8 for output" is set to "Yes").

Any idea about parameter to set (Domino/Linux)?

UPDATE

I'll try to explain better...

I call an agent through Ajax call. In parameter, i pass "ààà" string. When i try to decode in UTF-8 inside agent, string is resolved with

"???" 

instead of

"ààà"

This is what System.out.println() shows in console.

On another Domino server, everything works. I don't understand if it is a matter of server settings or OS settings.

Andrea Baglioni
  • 303
  • 1
  • 2
  • 20
  • What code are you using to work with the attachments? Try setting encoding using setEncoding("UTF-8") or if you work with bytes you can use getBytes("UTF-8") – Per Henrik Lausten Jun 05 '14 at 15:42
  • My understanding is that Linux filesystems do not have an inherent charset encoding. If you see accented characters correctly in your shell or GUI, it's because the locale settings you are using match the settings of the person who created the file. My recommendation is to write code that calles getBytes() with a variety of different charset arguments (utf-8, utf-16, etc.), and print out the results as hex codes. Match the results up against tables of charset encodings, and see what's really going on. – Richard Schwartz Jun 05 '14 at 18:14
  • Code for hex output: http://stackoverflow.com/questions/2817752/java-code-to-convert-byte-to-hexadecimal – Richard Schwartz Jun 05 '14 at 18:14
  • May be related to this. http://www-01.ibm.com/support/docview.wss?uid=swg21157964 – Simon O'Doherty Jun 07 '14 at 07:52

1 Answers1

2

Just a suggestion, but you could change the first line in your example to be:

OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream(), 
                                    Charset.forName("UTF-8"));

That will force the OutputStreamWriter to UTF8, and your sample code will show consistent output on both servers. Without knowing more details, I can't say for sure if that's relevant to the real problem.

Dave Delay
  • 1,292
  • 8
  • 12
  • In the update you said, "I don't understand if it is a matter of server settings or OS settings." Based on the code you've shown so far, I don't think it is a Domino server setting. It is more likely a JVM setting or a difference in OS behavior. But even if you find the magic switch, it's probably best to defensively fix the problem in code. Have any of our suggestions helped? – Dave Delay Jun 06 '14 at 12:30
  • Charset.forName("UTF-8") correctly force to UTF-8, but didn't solve the problem as reported in UPDATE section – Andrea Baglioni Jun 09 '14 at 05:34