encoding: write html file in java with ploish characters

  • Thread starter =?ISO-8859-1?Q?B=FClent_=D6ktem?=
  • Start date
?

=?ISO-8859-1?Q?B=FClent_=D6ktem?=

hi,

i have problems to write a html file in java with polish characters.
my method "writeContent( String s )" get an String from an XML Transformation.
if i look at the String in the debugger i see the polish characters correct.

but when i write it in a file, java makes '?' for some characters.
i've tried a lot of encodings for my OutputStreamWriter. with no effect.
can anyone help me?


private String encoding = "ISO-8859-2";
FileOutputStream fileOutStream = new FileOutputStream( filename );
OutputStreamWriter outWriter = new OutputStreamWriter( fileOutStream, encoding );

public void writeContent(String s)
{
try
{
outWriter .write(s);
outWriter .flush();
}
catch(Exception exception)
{
e.printStackTrace();
}
}
 
J

John C. Bollinger

Bülent Öktem said:
i have problems to write a html file in java with polish characters.
my method "writeContent( String s )" get an String from an XML Transformation.
if i look at the String in the debugger i see the polish characters correct.

but when i write it in a file, java makes '?' for some characters.

Which you determine how? Looking at the file after the fact with a text
editor, browser, or some such? Have you considered that whatever tool
you use to look at the generated file must (1) know what encoding is
applicable to the file and (2) understand that encoding? Many encodings
map the first 128 positions the same way that ASCII does, so encoding
problems are not always immediately obvious. Are you certain that the
most recent version of the program is writing / creating the output you
are examining?
i've tried a lot of encodings for my OutputStreamWriter. with no effect.
can anyone help me?

It might help if you provided a complete example that demonstrated your
problem. Or at least a compilable source. The below source would not
compile even if put inside a class because the FileOutputStream and
OutputStreamWriter constructors used can throw a checked exceptions.

You do, however, appear to be pursuing a reasonable general strategy.
The most robust choice of encoding (with respect to client support) is
probably UTF-8.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top