all groups > sql server programming > february 2005 >
You're in the

sql server programming

group:

Want to store chinese characters properly in database


Want to store chinese characters properly in database manisha_css
2/28/2005 9:43:03 PM
sql server programming:
I am working on MS SQL 2K and Java as backend. I want to store unicode data
that is coming from form HTML page. The problem is the data that is getting
stored to the database is ቅቚ etc instead of the correct letter value.
I have declared the filed type as nvarchar.

Pls pls help me, stuck like anything

regards
Re: Want to store chinese characters properly in database Madhivanan
2/28/2005 9:49:06 PM

Try to use Text Datatype

Madhivanan
Re: Want to store chinese characters properly in database manisha_css
2/28/2005 10:29:04 PM
Actually where the square boxes are appearng - "it is stored as &#.... (Html
format for unicode)"

But i want the value to get stored as unicode with UTF-8 encoding. i am
using this to render PDF through fop.

regards
Manisha



[quoted text, click to view]
Re: Want to store chinese characters properly in database manisha_css
2/28/2005 11:11:01 PM
Thanks Simon, will try it out one by one

regards
Manisha

[quoted text, click to view]
Re: Want to store chinese characters properly in database Steve Kass
3/1/2005 2:17:14 AM
Manisha,

Is it possible the Unicode data is being stored correctly,
but you are not using a Unicode font to view it?

If the web page generates a SQL Query to insert the data,
be sure it is putting the N prefix in front of any literal strings
that should be Unicode. The first of these two statements
will not work, but the second will:

insert into yourTable values ('中文')
insert into yourTable values (N'中文')

Steve Kass
Drew University


[quoted text, click to view]
Re: Want to store chinese characters properly in database Simon Shearn
3/1/2005 6:42:01 AM
[quoted text, click to view]

Hello -

I think nvarchar should work, but the problem may lie in some other part of
your system and it may be necessary to trace the problem through the
individual layers.
Some things to look at:
- check what encoding the the webpage is using (probably UTF-8, but might
not be)
- is the Java layer correctly handling the text coming from the webpage?
Does it know the encoding in use?
- is the Java layer transfering the text to the database correctly? Do your
stored procedures specify nvarchar parameters? If you're using dynamic SQL,
you may need to prefix your text values with N'
- is the database storing the text correctly. SQL Server uses UCS-2
internally so there may be UTF-8 to UCS-2 conversion issues.
- looking at unicode data in Query Analyser or Enterprise Manager can be
confusing. You may want to use the UNICODE() T-SQL function to examine
exactly what text the database is storing.
- when generating webpages, is the database sending text to the Java
correctly?
- when generating webpages, is the Java correctly incorporating the text
from the database into the webpages?

Regards,

Simon

RE: Want to store chinese characters properly in database Scott Simons
3/1/2005 8:09:09 AM
If this is coming from a web page, there are settings on the webpage you need
to change. It's has been a long time since I've done this but I think that
there are two different headers to set and a meta tag to ensure that all
browsers handle this correctly (I think the meta tag is needed for ie4.)
Re: Want to store chinese characters properly in database Uri Dimant
3/1/2005 8:45:00 AM
Hi
Define the column as NVARCHAR()/NCHAR()

Update Table SET col=N'Chine workd'


[quoted text, click to view]

AddThis Social Bookmark Button