----------
From: Martin Kuba makub@inet.cz
To: Java Apache Users java-apache-users@list.working-dogs.com
Subject: Re: Character encoding..
Date: Mon, 13 Sep 1999 13:40:14 +0200
mskang wrote:
>
> 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: makub@inet.cz
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
-------------------------------------------------------------------- |
----------
From: "Pawel Pesz" pawp@insert.com.pl
To: "Java Apache Users" java-apache-users@list.working-dogs.com
Subject: Re: Character encoding..
Date: Mon, 13 Sep 1999 14:29:33 +0200
mskang mskang@Helper.chunwoo.co.kr wrote:
>> where can i set default character encoding ? not specify
>> everytime i use it !! anybody knows it ?
Martin Kuba makub@inet.cz wrote:
> 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.
You can also set the "file.encoding" property. Add the
following to your "jserv.properties":
wrapper.bin.parameters=-Dfile.encoding=<your encoding>
It may be also useful to specify your default locale and
timezone:
wrapper.bin.parameters=-Duser.language=<your language> -Duser.region=<your country>
wrapper.bin.parameters=-Duser.timezone=<your timezone>
Best regards :-)
--
Pawel Pesz
InsERT.net, Wroclaw, Poland
webmasterATinsertDOTnetDOTpl
http://www.insert.net.pl |