-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------
mskang wrote:
>
> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
> i have had many problems to display Korean-characters with java.
>
> "i should use"
>
> out = new PrintWriter(new OutputStreamWriter(new
> FileOutputStream(filename,true),"KSC5601")); // write to a file (KSC5601
> is character encoding for Korean)
>
> "instead using"
>
> out = new BufferedWriter(new FileWriter(filename,true));
>
> "to correctly display our language."
>
> when i looked api reference for FileWriter class,
>
> "The constructors of this class assume that the default character
> encoding and the default byte-buffer size are acceptable. To specify
> these values yourself, construct an OutputStreamWriter on a
> FileOutputStream."
>
> where can i set default character encoding ? not specify everytime i use
> it !! anybody knows it ?
>
> --mskang
You do it wrong. When you want to send Korean text
to browser from Java servlet, do it as follows:
--------------------------------------------------------------
public void service (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out;
response.setContentType("text/html; charset=KSC5601");
out = response.getWriter();
try {
//add code here
out.println("...");
//-----
} catch (Exception ex) {out.println(ex.getMessage());ex.printStackTrace(out);}
}
--------------------------------------------------------------
If you want to write to files, do it as follows:
--------------------------------------------------------------
PrintWriter out
= new PrintWriter(
new OutputStreamWriter(
new FileOutputStream("koreanfile.txt"),"KSC5601"));
out.println("...");
--------------------------------------------------------------
If you want to use Korean encoding as default, you have to specify
it to your JVM. In WindowsNT, use "Regional settings", in UNIX,
use "LC_ALL=ko_KR java MyClass" for starting JVM.
Hope this helps
Martin
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
INET, a.s. Mgr. Martin Kuba
Kralovopolska 139 e-mail: [EMAIL PROTECTED]
601 12 Brno WWW: http://www.inet.cz/~makub/
Czech Republic tel: +420-5-41242414/33
--------------------------------------------------------------------
PGP fingerprint = D8 57 47 E5 36 D2 C1 A1 C3 48 B2 59 00 58 42 27
http://wwwkeys.cz.pgp.net:11371/pks/lookup?op=index&search=makub
--------------------------------------------------------------------
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]