Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 15757 invoked from network); 27 Nov 2008 02:27:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Nov 2008 02:27:43 -0000 Received: (qmail 80836 invoked by uid 500); 27 Nov 2008 02:27:41 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 80797 invoked by uid 500); 27 Nov 2008 02:27:41 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 80784 invoked by uid 99); 27 Nov 2008 02:27:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Nov 2008 18:27:41 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of milu71@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 27 Nov 2008 02:26:14 +0000 Received: (qmail invoked by alias); 27 Nov 2008 02:25:57 -0000 Received: from unknown (EHLO wladimir) [78.52.49.170] by mail.gmx.net (mp067) with SMTP; 27 Nov 2008 03:25:57 +0100 X-Authenticated: #48488578 X-Provags-ID: V01U2FsdGVkX19Bo8EiWMJBOx7DTHf4huLodt6/HKsyoA8kwbjVVW 8SzFKUrLKwhNcO Received: by wladimir (sSMTP sendmail emulation); Thu, 27 Nov 2008 03:25:47 +0000 Date: Thu, 27 Nov 2008 03:25:47 +0100 From: Michael Ludwig To: Tomcat Users List Subject: Re: Setting encoding for tomcat compiler Message-ID: <20081127022547.GF3836@wladimir> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.2i X-Y-GMX-Trusted: 0 X-FuHaFi: 0.46 X-Virus-Checked: Checked by ClamAV on apache.org Ronald Vyhmeister schrieb am 27.11.2008 um 08:47:07 (+0800): > In looking through the documentation, it looks like the default > encoding for the compiler is ISO-8859-1. Not quite. The javac man page (1.4, 1.6 ...) has this to say: -encoding encoding Set the source file encoding name, such as EUC-JP and UTF-8. If -encoding is not specified, the platform default converter is used. > I need to use Windows-1251 (Russian input). The javac compiler takes > an encoding option, but I have not figured out (maybe it's just too > late) how to make it use that encoding for all files (only one > application on the server, so no need to have multiple choices)... Always use that option. Or define an alias, if you're on UNIX. Or write a shell script calling javac with your options. Or if you use an IDE, configure it accordingly. > The database (postgresql) is UTF8, and will auto convert from WIN1251, > but right now it's receiving the stuff as LATIN1 (8859-1)... That doesn't have anything to do with javac, where you specify the *source file* encoding. An application dealing with different encodings has to be made aware of the issue. When reading text data, always specify the correct character encoding. If you read CP1251 and have your application believe it is Latin-1, your results won't make much sense. You must have code like this, which takes the encoding as parameter: C:\dev\Java\Encoding :: more /t1 Convert.java /* * Konvertiert von einer Zeichenkodierung in die andere. */ import java.io.*; public class Convert { public static void main( String[] args) throws IOException { assert args.length > 3 : "Argumente: Quelldatei Quellkodierung Zieldatei Ziellkodierung"; Reader in = null; Writer out = null; try { in = new BufferedReader( new InputStreamReader( new FileInputStream( args[0]), args[1])); out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( args[2]), args[3])); int c; while ( (c = in.read()) != -1 ) out.write( c); } finally { if ( in != null ) in.close(); if ( out != null ) out.close(); } } } C:\dev\Java\Encoding :: java -cp . Convert CP1251.txt latin1 Murks.txt utf-8 C:\dev\Java\Encoding :: more Murks.txt ????�???� ???�?�?�?�?�?�???� ?????�?�???? ???�?????? ???� ???�???�?? ???�?�?�??? �?? ?? ?????�???�?? Michael Ludwig --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org