From owner-freebsd-java@FreeBSD.ORG Thu May 20 23:55:25 2004 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BD5CB16A4CE for ; Thu, 20 May 2004 23:55:25 -0700 (PDT) Received: from diomedes.noc.ntua.gr (diomedes.noc.ntua.gr [147.102.222.220]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D16343D31 for ; Thu, 20 May 2004 23:55:25 -0700 (PDT) (envelope-from past@noc.ntua.gr) Received: from ajax.noc.ntua.gr (ajax.noc.ntua.gr [147.102.220.1]) i4L6sbl2044964; Fri, 21 May 2004 09:54:37 +0300 (EEST) (envelope-from past@noc.ntua.gr) Received: from [147.102.220.45] (hal.noc.ntua.gr [147.102.220.45]) by ajax.noc.ntua.gr (8.12.11/8.12.11) with ESMTP id i4L6saZ4054390; Fri, 21 May 2004 09:54:37 +0300 (EEST) (envelope-from past@noc.ntua.gr) Message-ID: <40ADA7AC.20407@noc.ntua.gr> Date: Fri, 21 May 2004 09:54:36 +0300 From: Panagiotis Astithas Organization: NTUA/NMC User-Agent: Mozilla Thunderbird 0.6 (X11/20040510) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sergei Komarov References: <009301c43eae$296f7b20$1401a8c0@na.corp.yr.com> In-Reply-To: <009301c43eae$296f7b20$1401a8c0@na.corp.yr.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-java@freebsd.org Subject: Re: JDK142_p6 - non-ascii encoding problem? X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2004 06:55:25 -0000 Sergei Komarov wrote: > Hello, > > I'm running FreeBSD 4.9-STABLE, jdk1.4.2_p6 and Tomcat 4.1.30 or 5.0.24 > and keep having a problem with non-Latin1 characters output by JSPs. > This problem seems to be specific to FreeBSD as it doesn't occur on > Windows (I'm testing Solaris as well). > > A JSP receives a request attribute containing a string of non-Latin1 > characters (Cyrillic Windows, Simplified Chinese gb2312, etc.) > > When the string is output within a page via c:out, struts bean:write or > <%=name%>, JspWriter converts all non-Latin1 chars to '?'. > > I can correct it with either of the following tricks, but the > application is too big to replicate them in all JSPs: > <%@page language="java" > contentType="text/html;charset=gb2312" > import= "java.nio.charset.*, > java.nio.CharBuffer, > java.nio.ByteBuffer" > %> > <% > String orig = (String) request.getAttribute("original"); > String encoded = new String(orig.getBytes("ISO-8859-1"),"gb2312"); > %> > ... > <%= encoded %> > ... > <% > Charset gb2312 = Charset.forName("gb2312"); > Charset iso = Charset.forName("ISO-8859-1"); > CharBuffer cb = CharBuffer.wrap(orig); > ByteBuffer bb = iso.encode(cb); > %> > ... > <%= gb2312.decode(bb) %> > > Am I missing something in the configuration of FreeBSD and JDK? > > I tried setting > LANGUAGE zh_CN > LANG zh_CN.gb2312 > LC_TYPE zh_CN > LC_ALL zh_CN > MM_CHARSET gb2312 > > In /etc/profile etc., but to no avail. Perhaps someone knows the > solution to this? You could try adding the following to the default class in /etc/login.conf: :charset=zh_CN.GB2312:\ :lang=zh_CN.GB2312:\ and then doing "cap_mkdb /etc/login.conf". You could also have just mis-spelled the locale. Cheers, -- Panagiotis Astithas Electrical & Computer Engineer, PhD Network Management Center National Technical University of Athens, Greece