Problems in displaying chinese characters with utf-8 encoding
Hi,
I got problem in displaying chinese characters in my web application.
I am creating a web application supporting both English and Chinese charaters. What I am trying to do is:
1. storing some chinese characters via a web page (page1) into database.
2. retrieve the chinese characters via another web page (page2) from the database.
Once I put the Chinese characters on the webpage (page1 in step #1), it displayes well (the readable chinese characters) before I submit this page (after submit, the data will be stored into the database).
But when I tried to display the chiese characters via page2 in step#2, I got un-readable characters displayed.
The running configuration is: Sun Application Server (coming and with the JSC2) and MySQL server 5.0. And I setup the database server with utf8 as character-set.
It seems like the chinese characters got messed up throught the round-trip (from page1<----via jdbc---->database<----via jdbc------>page2).
From the database, I found the chinese characters are there. Any helps are appreciated.
Hi,
I am trying to insert new record.The record may contain chineese or English data.
I did same what u specified.
first I converted to the byte UTF8.again,I converted byte to string using 8859_1.
the values are not storing chinese characters.
pls suggest me.
below is my code.
ascCode = req.getParameter("asccode");
countryCode = req.getParameter("countrycode");
ascName = req.getParameter("ascname");
address1 = req.getParameter("ascaddress1");
address2 = req.getParameter("ascaddress2");
System.out.println("ASC NAME:"+ascName);
System.out.println("ADDRESS1:"+address1);
System.out.println("ADDRESS2:"+address2);
ascC = ascCode.getBytes("UTF8");
coun = countryCode.getBytes("UTF8");
ascN = ascName.getBytes("UTF8");
add1 = address1.getBytes("UTF8");
add2 = address2.getBytes("UTF8");
System.out.println("ASC NAME:"+ascN);
System.out.println("ADDRESS1:"+add1);
System.out.println("ADDRESS2:"+add2);
ascCode = new String(ascC,"8859_1");
countryCode= new String(coun,"8859_1");
ascName = new String(ascN,"8859_1");
address1 = new String(add1,"8859_1");
address2 = new String(add2,"8859_1");
System.out.println("ASC NAME:"+ascName);
System.out.println("ADDRESS1:"+address1);
System.out.println("ADDRESS2:"+address2);
thanks.
Similar Messages
-
Problem in displaying chinese characters in chinese OS
I have a application that is supposed to run on chinese OS. But i can't seem to make it display in the correct language format, whether its big5 or gb2312.
When saving chinese characters to db, it saves weird characters to the db and retreive the weird characters to be displayed on the web.
Do I need to do any changes to anything ??
Thank you in advance.
current system requirements:
Chinese OS (NT4)
Access DB (English version)
Java / JSP languages
Display big5 or GB2312Try using varchar
-
To display chinese characters with SQL Developer
I have created one table on the Oracle Express Database. In this table ther is one field Nchar tipe.
The NLS_CHARACTERSET of the d.b. is WE8MSWIN1252, the NLS_NCHAR_CHARACTERSET is AL16UTF16.
I have done an insert on the table and in this field i have inserted this word: 了解更多
When i do a select comand with sql developer, on the results i see this only this •••• .
But if i copy this and cut on the Sql Developer editor, i see the corret word.
How could i configurate ?
Regards
MarioHi
The following works but there may be better solutions:
http://totierne.blogspot.com/2008/05/issuesquare-boxes-as-text-characters.html
Issue:Square boxes as text characters Solution:Add fonts
Chinese characters in Linux see Debian Chinese How To [1] basically:
1. create a jre/lib/fonts/fallback directory if necessary and
2. copy or link the fonts files into this directory. (On my Linux system: /usr/share/fonts/truetype/arphic/gbsn00lp.ttf )
-Turloch -
Displaying chinese characters in browser
Dear sirs,
I am having the following issue in chinese internationalization.when i stored the JSP form parameters(typed in chinese) in database,it stored some kind of junk characters ....and when i displayed ,they showed like SMALL SMALL tables.... in my browser.
Our project is java based web application.
Java-1.5
Mysql-5.0.24
tomcat-5.5
JSP-1.2
servlet-2.0
browser-mozilla firebox
I set in my all JSP pages,
----->1.<%@ page contentType="text/html;charset="UTF-8" pageEncoding="UTF-8"%>
----->2.<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
in my JAVA files,i added,
----->String encode=ServletContext.getInitParameter("javaEncoding");
----->request.setCharacterEncoding(encode); (it gets encoding UTF-8 from web.xml file)
In my MYSQL,i set...
----->mysql --default-character-set=utf8 -username -password -database
so,i changed client,connection,results,system charactersets " utf8" and connection collation is "utf8".
In my DATABASE connection String...i added,
------>useUnicode=true&characterEncoding=UTF-8
In my TOMCAT web.xml file..i added these lines as i am using POST method for form.
<context-param>
<param-name>javaEncoding<param-name>
<param-value>UTF-8<param-value>
<context-param>
still .i am unable to display chinese characters in my browser.
but.when i am using getBytes() for all form parameters in JAVA file....i m able to store chinese in db and dispay in browser ....
String param;
---->String param=newString(param.getBytes("ISO8859-1"),"UTF-8");
Could anyone tell me another method for displaying chinese except this getBytes()..
please help me out. i am trying to find out an alternative server-independent method for past two weeks.
Advance thanks for reading and help.
mullaimaran.Hi one_dane &Mr.Clap,
Thank you for your help.
At last i displayed chinese characters with out using getBytes() and web.xml configuration.
My settings for displaying chinese....
JSP :
1<%@ page contentType="text/html;charset="UTF-8" pageEncoding="UTF-8"%>2.<HEAD>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</HEAD>JAVA(Servlet):
request.setCharacterEncoding("UTF-8");MYSQL:
Mysql connection String...i added,
----> useUnicode=true&characterEncoding=UTF-8i m using linux terminal for mysql login.
bash]$ mysql --default-character-set=utf8 -username -password -database nameSo, i changed these settiings in database
mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+and set collation....
mysql> show variables like '%col%';
+---------------------------+-------------------+
| Variable_name | Value |
+---------------------------+-------------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |Once again thank you....for help.Keep your assistance in this forum.
mullaimaran. -
Problem displaying chinese characters
I have got the problem with displaying chinese characters in the webpage after fetching the data from database.
I am using Oracle IAS webserver and oracle 8i as the database which is in UTF-8 characterset.I am getting the out put in the chinese if I use this code.
String value1 = new String(value.getBytes("ISO8859_1"), "GB2312");
I am getting the out put using this code in this format
��������
比分卡片 basically this code does that.(String value1 = new String(value.getBytes("ISO8859_1"), "GB2312");)
But some body told me that I have to do some settings in the server.I am using oracel IAS.Can you suggest me any thing?.
Here is my full code
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.nio.charset.Charset,java.util.Locale,org.apache.struts.action.*,java.io.*,javax.naming.Context,java.sql.Connection,javax.sql.DataSource,javax.naming.InitialContext,java.sql.*" %>
<HTML><HEAD><TITLE>Welcome to METRO</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Encoding" content="UTF-8"/>
</HEAD>
<BODY >
<style type="text/css">
.tb {
border: 1px solid #ddd;
border-collapse: collapse;
font-family:arial ,sans-serif;
font-size: small;
height:100%;
width:100%;
color:#00000000;
</STYLE>
<%
String value="";
try{
Connection dbConn;
Statement stmt=null;
Context jndiCtx=new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)jndiCtx.lookup( "jdbc/webdbPooledDS" );
dbConn= ds.getConnection();
stmt=dbConn.createStatement();
String sql="select prog_name_LL2 from test_table where table_name='test'";
ResultSet rs = stmt.executeQuery(sql);
if( rs.next()){
value=rs.getString(1);
System.out.println("value="+value);
out.println("<table class='tb'><tr><td>"+value+"</font><br>");
String value1 = new String(value.getBytes("ISO8859_1"), "GB2312");
out.println(""+value1+"</td></tr></table>");
rs.close();
stmt.close();
dbConn.close();
}catch(Exception e){
System.out.println("Exception ="+e.getMessage());
%>
</BODY></HTML>Follow the steps as listed below:
1. Is the Font available on Printer
Goto SP01 transaction -> Enter the Spool Number -> Execute
2. Does device type/Spool Server support the font
Goto Transaction SPAD and click Output Devices
3. SAP level Multibyte setting in place
Click ALT + F12
Select Options -> I18N
Tick Activate Multibyte functionality
4. Is appropriate font for the language used
For Simplified Chinese (ZH) language use font CNHEI, CNKAI, CNSONG
SAP Notes related to Fonts
a.0000776507 SAPscript/SmartForms: Which fonts for which languages?
b.0000323736 Restrictions with "PDF print" through spooler
c.0000317851 Creating PDF format using the SAP spooler in 4.6C/4.6B/4.5B
d.0000012462 How can I define a new printer font?
e.Note 62178 Device types for the Japanese version of the R/3 System -
Problems displaying Chinese characters
Safari cannot display Chinese characters from time to time. It would work in one session but it failed to display Chinese characters in another session even with the same settings in the Preferences. Can anyone give me some advice please?
Safari cannot display Chinese characters from time to
time. It would work in one session but it failed to
display Chinese characters in another session even
with the same settings in the Preferences. Can
anyone give me some advice please?
The preferences don't necessarily matter. You most likely need to adjust the encoding in View > Text Encoding. If you will provide the url of an example page where you have a problem I can probably offer more specific help. -
[SOLVED] Problems opening folders with UTF-8 encoded characters
Hello everyone, I'm having an issue when I acess folders in all my programs ( except Dolphin File Manager). Every time I open the folder navigation window in my programs, folders with UTF-8 encoded characters ( such as "ç", "á ", "ó", "í", etc ) are not shown or the folder name not show these characters, therefore, I can not open documents inside these folders.
However, as you saw, I can type these characters normally. Here's my "locale.conf" :
LANG="en_US.UTF-8:ISO-8859-1"
LC_TIME="pt_BR.UTF-8:ISO-8859-1"
And here's the output of the command "locale -a" :
C
en_US.utf8
POSIX
Last edited by regmoraes (2015-04-17 12:55:19)Thing is, when I run locale -a, I get
$ locale -a
C
de_DE@euro
de_DE.iso885915@euro
de_DE.utf8
en_US
en_US.iso88591
en_US.utf8
ja_JP
ja_JP.eucjp
ja_JP.ujis
ja_JP.utf8
japanese
japanese.euc
POSIX
So an entry for every locale I have uncommented in my locale.conf. Just making sure, by "following the steps in the beginner's guide", you also mean running locale-gen?
Are those folders on a linux filesystem like ext4 or on a windows (ntfs?) -
Chinese Data Fields not displaying Chinese Characters
Hi There,
Wonder if someone can help. We are currently running reports in Crystal 8.5 but are in the process of upgrading our business systems to latest version and this includes converting all our Crystal 8.5 reports to Crystal Reports XI R2 SP4.
During the process we are experiencing some difficulties in displaying Chinese characters, which have previously worked fine in version 8.5. The system we are running Crystal from has Oracle client 11 installed and the OS system locale is set to Chinese PRC. Our application is displaying Chinese characters properly and if we have any text fields on the report, these are also displaying properly when changing Font to Arial Unicode MS. The only thing that doesn't display properly is the field data which after checking has the correct Chinese data stored in the database. For some reason Crystal 11.5 doesn't seem to be transferring the data correctly which points to some sort of encoding problem.
Is there something I am missing here or is there something else I need to install for this to work?
Any hep would be appreciated.What is your Oracle database's language set? Is it set to UTF-8 or non UTF-8 (such as American_America.WE8ISO8859P1" )?
There is a similar issue tracked under ID ADAPT00528561 (Crystal cannot display non-UTF-8 Chinese characters from an Oracle database ) and has been fixed and you should set the following registry key to make it effective:
Set the following registry key "UseOSLocaleForConversion" to "Yes" under:
HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.5\Crystal Reports\Database\Oracle -
Displaying Chinese characters in SQL*Plus
DB version: 11.2
OS Version : AIX 6.1
DB characterset:AL32UTF8
To display chinese characters in SQL*Plus, I did the following:
$ export LANG=zh_CN.UTF-8
$ export LC_ALL=zh_CN.GB2312
$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
$
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on ÐÇÆÚÈý 5ÔÂ 2 15:52:33 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option
SQL> ALTER SESSION SET NLS_LANGUAGE='SIMPLIFIED CHINESE';
Session altered.
SQL> ALTER SESSION SET NLS_TERRITORY='CHINA';
Session altered.
SQL> select unistr('\8349') from dual; ---- not 100% sure if this is the way to verify if chinese characters can be displayed.
UN
²Ý ----------------------------------------> Getting a junk character instead of chinese If I was using putty, are the above steps enough to get chinese characters displayed ?
Our ssh client is Tectia (not putty).
According the below ML Note, the SSH client has to configured correctly to use globalization features.
+The correct NLS_LANG setting in Unix Environments [ID 264157.1]+
Googling "Tectia + Chinese" didn't return useful resultsI understand that you are talking about Windows SSH Client.
For Putty, you should set:
$ export LANG=zh_CN.UTF-8
$ export LC_ALL=zh_CN.UTF-8
$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
and configure Putty in Window->Translation to use UTF-8.
There is nothing about this subject on Tectia website and in their manuals, so my best guess is that the client requires Windows code page to work correctly. In such case you need to set your Windows system default locale (locale for non-Unicode programs) to Chinese and use the following settings on the server:
$ export LANG=zh_CN.GBK
$ export LC_ALL=zh_CN.GBK
$ export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
Verify with 'locale -a' that the setting zh_CN.GBK is supported on your system.
-- Sergiusz -
Cannot Input and Display Chinese Characters by using ODBC Applications
Dear all,
I am trying to input the Simplified Chinese Characters in the Oracle Database Ver 9.2 running on a UNIX AIX server. The client application we are using is th MS Access 2003 running on a MS Windows XP English version SP 2 without multi-language pack. MS Office 2003 is also an English version.
Database setting is:
NLS_CHARACTERSET=US7ASCII
NLS_NCHAR_CHARACTERSET=AL16UTF16
The Oracle Client used is also ver 9.2 with the ODBC driver ver 9.2. I have tried the following NLS_LANG settings by chaging the registry without any NLS_LANG environment settings:
AMERICAN_AMERICA.ZHT16MSWIN950
AMERICAN_AMERICA.ZHS16GBK
AMERICAN_AMERICA.ZHT16HKSCS
AMERICAN_AMERICA.AL32UTF8
I have tied to load some Chinese Characters in by sqlload and by using the NLS_LANG AMERICAN_AMERICA.ZHT16MSWIN950, AMERICAN_AMERICA.ZHS16GBK and AMERICAN_AMERICA.ZHT16HKSCS, they can be display perfectly in SQLPLUS. But when using the same NLS_LANGs and display in the ACCESS, only ???? are displayed.
When I tried to insert Chinese in ACCESS, the character changed to ???? again. No matter what Chinese characters I inserted by MS ACCESS, the ???? code can be dump with the binary code "03, 0f".
Are there any methods or settings I need to change to make ACCESS an application for inserting and displaying Chinese characters from the Oracle database?
I have tried to set the Non-Unicode setting in the Windows Locale setting:
Chinese (Taiwan) (With AMERICAN_AMERICA.ZHT16MSWIN950),
Chinese (Hong Kong S.A.R) (with AMERICAN_AMERICA.ZHT16HKSCS) and
Chinese (PRC) (with AMERICAN_AMERICA.ZHS16GBK)
when inserting the Chinese Characters by Access. But they all failed with ???? inserted in the DB.
Please kindly advise what should be done.
Thanks.Are you trying to store the character data in char/varchar2 columns?
If that's the case then you have a problem, since a US7ASCII character set can only handle, well, ascii data.
If you are trying to store the data in columns of nchar datatypes, then there might be a problem with literals because literals are converted to database character set first, before conversion to national (nchar) character set. Such data loss can also happen depending on how binds or oci calls are performed.
You could use the dump() function to verify what's actually stored in a database column, without a db - client conversion happening that may distort the facts.
Example:
SQL> select col, dump(col, 1016) from table where some_condition; -
The "blue bar" no longer properly displays Chinese characters.
I recently updated my Adobe Reader from 7 to 9.4, and since doing so, Firefox no longer displays Chinese characters in the title bar. Instead, I now only see question marks.
I've added Chinese to the preferred languages and also tried switching the browser's text to Unicode, but neither of these has made a difference.
It's certainly a minor issue, but if anyone knows what to do, I'd greatly appreciate the help!
Thanks!A possible cause is that Firefox has a problem with the (system) font that is used to display the Chinese characters on the title bar.
Were any new fonts installed recently?
You can try to use the system file checker to see if there are any problems with font files.
See Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe): http://support.microsoft.com/kb/310747 -
Hi, am trying to display chinese characters
hi,..i have problem displaying chinese characters using the reporting tools. i even changed the .jsp to use UTF8 encoding but the jsp doesnt display the correct chinese characters. Anyone can help ?
Hi Teo Kai Liang,
In order to display UTF-8 characters in the web output of your report, when it is deployed using the JSP engine (instead of rwservlet), you would need to add the following tag to its JSP web source in Reports Builder, between the <HEAD> and </HEAD> tags:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
This will tell the browser to display text using the specified character set. I have verified this using a report containing some static Simplified Chinese text in its web source.
Thanks,
The Oracle Reports Team. -
JEditorPane -- displaying chinese characters in browser
Is it possible to display chinese characters in an applet in a browser, I have read Jaric S.'s article on it.. but it is a little confusing.. however without doing any of that coding I have chinese showing up on one machine in IE, but not on any other machines with IE. Any thoughts anyone?
Is it possible to display chinese characters in an
applet in a browser, I have read Jaric S.'s article on
it.. but it is a little confusing.. however without
doing any of that coding I have chinese showing up on
one machine in IE, but not on any other machines with
IE. Any thoughts anyone?Browser Java is particularly sensitive to the version of Java the browser supports. Some browser companies, notably Microsoft, haven't updated their Java implementation in 4 years. Likewise users who are using old versions of other browsers probably have old versions of Java. This makes it very hard to predict how anything will work when it depends on a browser's VM.
There are two ways to combat this. First you can use Sun's Java Plugin to replace the VM used by your browser with a modern one that supports your applet. Second, you can use Java WebStart which allows programs to be launched from a browser but run in an independant VM. These two things might help you get consistent results for your applets.
Hope this helps,
Brian. -
How to display Chinese characters in Oracle?
I am using Oracle 8i with Language settings as AMERICA.
I am displaying records which is contain Chinese characters.
But it is not displayed properly in Oralce.
How to change the settings to display Chinese characters?
ThanksIt could be possible to display Chinese characters using SQL Developer without any specific NLS_LANG setting because SQL Developer is using JDBC which doesn't use NLS_LANG setting according to When is NLS_LANG used ?.
For example, I'm able to display the following Chinese character in SQL Developer 1.2.0 on Windows XP Pro with French Windows setting and NLS_LANG set in Windows registry to FRENCH_FRANCE.WE8ISO8859P1.
select unistr('\8349') from dual;
草
[pre]
Message was edited by:
Pierre Forstmann -
Problem to insert Chinese Characters(GB3212) into MySQL
I met a problem to insert Chinese Characters (GB3212) into MySQL using Entity Bean (or JPA).
For example, when a hardcoded string "{color:#ff0000}电器me元件{color}" is inserted, it is displayed as "{color:#ff0000}??me??{color}" in MySQL.
The NamedQuery is also not working for Chinese Characters.
The setting are as following:
GlassFish JDBC connection pool: useUnicode=true, charecterEncoding=gb2312
NetBeans IDE: source encoding set to GB2312;
MySql table: the column set to CHARACTER SET gb2312;
Any experts, please give advice
Thanks lotI didn't noticed that there is a {color:#ff0000}sun-resources.xml{color} file under {color:#ff0000}<ejb project>/server resources{color}.
This file has a pool configuration. This config just overwite the paremeter i added using Admin Console every time a client is lauched. So there are two option to fix this problem.
1. Insert the follwowing two lines into the {color:#ff0000}sun-resources.xml{color}
<property name="characterEncoding" value="gb2312"/>
<property name="useUnicode" value="true"/>
2. delete the everthing in the {color:#ff0000}sun-resources.xml, using Admin Console {color}config your own pool & DataSource
I tried first option & it works.
Maybe you are looking for
-
How do I install Canon MX922 Fax function, printer works but fax not recognized??
I can print wirelessly using my new Canon MX922 Multifunction printer/scanner/fax. My iMac doesn't seem to recognize the fax function. I would like to be able to send documents straight to the fax without printing them first. Can anyone help?
-
Configure AE in WDS mode to share NAS in wireless network?
How do I configure latest airport express in "extend existing network" mode to connect a network hdd (mybook live) LAN/WAN to the wireless network?
-
I put a password on my phone and forgot it how can I unlock
How do I unlock my phone pass code I set one and I forgot it last night?
-
Hardware Test Error Message - Mass Storage Error code ata 1/6/8 HD: 2,0
I have an imac 15" flat Panel, 700 MHz . after getting the flashing question mark, running or trying to run all the standard tests, (pram, Software Restore, disk repair, reinstall, kernel repairs) I never see the hard drive or volume. I saw it was a
-
Error "Operation in order 221234 doesnot exist" while doing confirmation
Hello Friends, When i am doing the collective confirmation against the corrective maintenance order or order type CORR, by transaction IW44, getting the error message as "Operation in order 221234 doesnot exist". Whereas when i checked in PM Order ,