RE: Struts 1: character encoding

2009-10-06 Thread Martin Gainty

try to add in the character set you need to MySQL 5.4+
http://dev.mysql.com/doc/refman/5.4/en/adding-collation-unicode-uca.html

if you cant locate the charset this means the characters you are adding are 
UTF-16 characters in which case you'll need to configure UTF-16 for both mysql 
and your container 

personally I have i couldnt get chinese colation to work with UTF-8 or any info 
is incorrect

$MYSQL_HOME/share/charsets/index.xml




 Copyright (C) 2003 MySQL AB
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 2 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



This file lists all of the available character sets.
To make maintaining easier please:
 - keep records sorted by collation number.
 - change charsets.max-id when adding a new collation.



  Traditional Chinese
  Big5 Traditional Chinese
  big-5
  bigfive
  big-five
  cn-big5
  csbig5
  
primary
compiled
  
  
binary
compiled
  
<..snip..>



mysql> show collation like 'big5_chinese_ci';
+-+-++-+--+-+
| Collation   | Charset | Id | Default | Compiled | Sortlen |
+-+-++-+--+-+
| big5_chinese_ci | big5|  1 | Yes | Yes  |   1 |
+-+-++-+--+-+
1 row in set (0.02 sec)

mysql> CREATE TABLE phonebook ( name VARCHAR(64), phone VARCHAR(64) CHARACTER SE
T utf8 COLLATE big5_chinese_ci);
ERROR 1253 (42000): COLLATION 'big5_chinese_ci' is not valid for CHARACTER SET '
utf8'

feel free to correct if you found a way to install big5_chinese_ci on UTF-8
Martin Gainty 
__ 
BTW: all these languages listed here are UTF-8 languages:
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.




> Date: Tue, 6 Oct 2009 10:49:41 -0700
> From: tommy...@yahoo.com
> Subject: Re: Struts 1: character encoding
> To: user@struts.apache.org
> 
> - Original Message 
> > From: senderj 
> > To: user@struts.apache.org
> > Sent: Tue, October 6, 2009 3:28:08 AM
> > Subject: Struts 1: character encoding
> > 
> > 
> > The components I use NetBean, Glassfish, Struts 1, EJB, Toplink, jdbc, 
> > MySQL.
> > Basically what I want is to extract info from a web site (utf8 encoded
> > Chinese), store the info in MySQL, retrieve the info and display on my web
> > site for user to update/change it. But I got problem on the character
> > encoding. Here is briefly my logic and coding:
> > 
> > (1) extract from a web page which uses UTF-8 encoded, my coding in an EJB
> > run on glassfish:
> > char c = (char) myInputStream.read();
> > Listtoken;
> > token.add((byte) c);
> > byte[] ba = new byte[token.size()];
> > for (int i=0; i
> > ba[i] = token.get(i);
> > }
> > String s = new String(ba, "UTF-8");
> > 
> > I know it can be simpler, but it's a copy of others coding + my
> > amendment. But it works.
> > 
> > (2) String s above is stored onto MySQL via toplink, jdbc. Table is DEFAULT
> > CHARSET=utf8. The jdbc URL is
> > jdbc:mysql://mysys:3306/testing&useUnicode=true&characterEncoding=utf-8.
> > 
> > (3) Retrieve by Struts Action via EJB. Both EJB 

Re: Struts 1: character encoding

2009-10-06 Thread Tommy Pham
- Original Message 
> From: senderj 
> To: user@struts.apache.org
> Sent: Tue, October 6, 2009 3:28:08 AM
> Subject: Struts 1: character encoding
> 
> 
> The components I use NetBean, Glassfish, Struts 1, EJB, Toplink, jdbc, MySQL.
> Basically what I want is to extract info from a web site (utf8 encoded
> Chinese), store the info in MySQL, retrieve the info and display on my web
> site for user to update/change it. But I got problem on the character
> encoding. Here is briefly my logic and coding:
> 
> (1) extract from a web page which uses UTF-8 encoded, my coding in an EJB
> run on glassfish:
> char c = (char) myInputStream.read();
> Listtoken;
> token.add((byte) c);
> byte[] ba = new byte[token.size()];
> for (int i=0; i
> ba[i] = token.get(i);
> }
> String s = new String(ba, "UTF-8");
> 
> I know it can be simpler, but it's a copy of others coding + my
> amendment. But it works.
> 
> (2) String s above is stored onto MySQL via toplink, jdbc. Table is DEFAULT
> CHARSET=utf8. The jdbc URL is
> jdbc:mysql://mysys:3306/testing&useUnicode=true&characterEncoding=utf-8.
> 
> (3) Retrieve by Struts Action via EJB. Both EJB and Action does not have
> change of string encoding. The Action put the Chinese string into a
> DynaForm, then to JSP. JSP has <%...@page contentType="text/html"
> pageEncoding="UTF-8"%> and it generates an html input form.
> 
> (4) However, the Chinese characters were NOT displayed properly in the html
> form on IE.
> 
> (5) Anyway, in the html form, I override the incorrect Chinese character by
> a writing pad with the correct characters (equivalent to unicode "9326
> 6c5f") and submit. Again, no re-encoding in the Action that process the
> update. The Action calls an EJB to update the database with the input data.
> But I found that the database was updated with ascii string
> "錦江" (exactly this string, not its equivalent
> encoded).
> 
> I feel somehow there is/are encoding changes done by the software components
> I use (Struts? toplink? jdbc?), but don't know which one and I may be wrong.
> If anybody has any idea on this problem please help.
> -- 
> View this message in context: 
> http://www.nabble.com/Struts-1%3A-character-encoding-tp25766281p25766281.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org

If you're using Tomcat and doing POST via URL, you need to change Tomcat's URL 
charset encoding.  Default is ISO-8859-1, if I remember correctly.

Regards,
Tommy


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Struts 1: character encoding

2009-10-06 Thread senderj

The components I use NetBean, Glassfish, Struts 1, EJB, Toplink, jdbc, MySQL.
Basically what I want is to extract info from a web site (utf8 encoded
Chinese), store the info in MySQL, retrieve the info and display on my web
site for user to update/change it. But I got problem on the character
encoding. Here is briefly my logic and coding:

(1) extract from a web page which uses UTF-8 encoded, my coding in an EJB
run on glassfish:
char c = (char) myInputStream.read();
List token;
token.add((byte) c);
byte[] ba = new byte[token.size()];
for (int i=0; i and it generates an html input form.

(4) However, the Chinese characters were NOT displayed properly in the html
form on IE.

(5) Anyway, in the html form, I override the incorrect Chinese character by
a writing pad with the correct characters (equivalent to unicode "9326
6c5f") and submit. Again, no re-encoding in the Action that process the
update. The Action calls an EJB to update the database with the input data.
But I found that the database was updated with ascii string
"錦江" (exactly this string, not its equivalent
encoded).

I feel somehow there is/are encoding changes done by the software components
I use (Struts? toplink? jdbc?), but don't know which one and I may be wrong.
If anybody has any idea on this problem please help.
-- 
View this message in context: 
http://www.nabble.com/Struts-1%3A-character-encoding-tp25766281p25766281.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org