By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

Storing japanese characters

P: n/a
I'm trying to make a site work for japanese characters. It works fine
except for the alerts in javascript.

The characters are stored in unicode, as this;
'コミック全巻配'

Those unicode characters are translated by the browser, but not in the
alert.
Am I storing it correct in the db (コ)? Or should I store the
japanese characters instead of the unicode?
Thanks in advance!
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Daniel (fa*********@hotmail.com) writes:
I'm trying to make a site work for japanese characters. It works fine
except for the alerts in javascript.

The characters are stored in unicode, as this;
'コミック全巻配'

Those unicode characters are translated by the browser, but not in the
alert.
Am I storing it correct in the db (コ)? Or should I store the
japanese characters instead of the unicode?


It's not really clear to me what you store in the database. Do you store
the string コ in the database? This does not seem like a good thing
to do. You should store the character itself in an nvarchar column.

I don't know Javascript, so I have no idea what is happening there.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

P: n/a
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Daniel (fa*********@hotmail.com) writes:
I'm trying to make a site work for japanese characters. It works fine
except for the alerts in javascript.

The characters are stored in unicode, as this;
'コミック全巻配'

Those unicode characters are translated by the browser, but not in the
alert.
Am I storing it correct in the db (コ)? Or should I store the
japanese characters instead of the unicode?


It's not really clear to me what you store in the database. Do you store
the string コ in the database? This does not seem like a good thing
to do. You should store the character itself in an nvarchar column.

I don't know Javascript, so I have no idea what is happening there.


Thanks for your answer.

Yes, I do/did store the string #12467; in the database.

I tried to insert it throught the Enterprise manager (copying from a
japanese site - yahoo.co.jp), but only some squares appears, and they
turn into questionmarks on the site. However, when I copy the squares
and paste somewhere else, the correct japanese characters appears.

So probably it was inserted correctly in the db, but maybe the my
computer and the webserver need to have japanese characters installed?
Jul 20 '05 #3

P: n/a
Daniel (fa*********@hotmail.com) writes:
So probably it was inserted correctly in the db, but maybe the my
computer and the webserver need to have japanese characters installed?


Indeed. Without a Japanese font it's difficult to read Japanese text! (The
web server should not be an issue, though. It only transfers the bytes).

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4

P: n/a
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Daniel (fa*********@hotmail.com) writes:
So probably it was inserted correctly in the db, but maybe the my
computer and the webserver need to have japanese characters installed?


Indeed. Without a Japanese font it's difficult to read Japanese text! (The
web server should not be an issue, though. It only transfers the bytes).


Thanks for your answer!

Is there anything else I need to do in the database, like set a
collation for this field? I rather wouldn't do that, since it's
suppose to store data from various locales.
I installed japanese characters btw, so it didn't explain the
questionmarks I get on the screen.
I found a solution for my problem with the alert when storing the
codes of the characters (実装), but it seems that storing
the proper japanese characters is the path to take. I mean, '実'
occupies 8 times the space compared to only one character (doesn't
it?).
Jul 20 '05 #5

P: n/a
Daniel (fa*********@hotmail.com) writes:
Thanks for your answer!

Is there anything else I need to do in the database, like set a
collation for this field? I rather wouldn't do that, since it's
suppose to store data from various locales.
You should be using the nvarchar datatype to that. As for the collation,
it matters when comparing and sorting. But doing operations on multi-
lingual data can be immensly complex.
I installed japanese characters btw, so it didn't explain the
questionmarks I get on the screen.


I had some problems in following where you were doing what. But a simple
test is to say:

CREATE TABLE Japanese (a nchar(1) NOT NULL)
go
INSERT Japanese(a) VALUES (nchar(23255))

Then try to display that character in various places.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6

P: n/a
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
I installed japanese characters btw, so it didn't explain the
questionmarks I get on the screen.

I had some problems in following where you were doing what. But a simple
test is to say:

CREATE TABLE Japanese (a nchar(1) NOT NULL)
go
INSERT Japanese(a) VALUES (nchar(23255))

Then try to display that character in various places.

I inserted it throught the Enterprise Manager before, by copying a
character. I also inserted as you suggested. It looks correct in the
database - it displays as a japanese character.

But on the webpage it only displays questionmarks.

I have installed japanese characters on my computer - not on the
server. I don't think it's installed there. I guess that is the
problem.
Thanks for your help.
/Daniel
Jul 20 '05 #7

P: n/a
Daniel (fa*********@hotmail.com) writes:
I inserted it throught the Enterprise Manager before, by copying a
character. I also inserted as you suggested. It looks correct in the
database - it displays as a japanese character.

But on the webpage it only displays questionmarks.

I have installed japanese characters on my computer - not on the
server. I don't think it's installed there. I guess that is the
problem.


Since "Japanese characters" in this context is a font issue that is
not likely to be the cause. But it could have to do with how the
web page looks like, for instance which character set you have defined
in the HTTP header. There seems to be some character conversion going
on, and the ? is a fallback character for something that cannot be
converted.

Not that I know much about web server, but what web server are you
using, and how to you access the SQL Server from the web server?

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #8

P: n/a
Erland Sommarskog <es****@sommarskog.se> wrote in message news:<Xn**********************@127.0.0.1>...
Daniel (fa*********@hotmail.com) writes:
I inserted it throught the Enterprise Manager before, by copying a
character. I also inserted as you suggested. It looks correct in the
database - it displays as a japanese character.

But on the webpage it only displays questionmarks.

I have installed japanese characters on my computer - not on the
server. I don't think it's installed there. I guess that is the
problem.


Since "Japanese characters" in this context is a font issue that is
not likely to be the cause. But it could have to do with how the
web page looks like, for instance which character set you have defined
in the HTTP header. There seems to be some character conversion going
on, and the ? is a fallback character for something that cannot be
converted.
e
Not that I know much about web server, but what wb server are you
using, and how to you access the SQL Server from the web server?


I'm using IIS 5.0 and ASP to access the SQL Server.
We found a solution to the problem. It turns out it's necessary to
save the ASP-file converted to utf-8. So now I need to resave ALL the
files..:/

Thanks for your help, Erland!
Jul 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.