Storage of Chinese, Korean, English, etc. In MS SQL through SQL Express

I use MS SQL 2008 Express to connect to a shared MS SQL 2008 server, where I have a database. The default collation value for the database is currently SQL_Latin1_General_CP1_CI_AS . Ultimately, I would like to store English, Korean, Chinese and any other language imaginable in the database. I started by using the following SQL code (which I found here: http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/5d2ea1a2-32e1-4a82-b6e3-17d2b898babc/ ) to check:

 create table zhongwen(mingzi nvarchar(10)) go insert into zhongwen values (N'有方') insert into zhongwen values (N'李杰') insert into zhongwen values (N'空炮鸡蛋') go select * from zhongwen go create procedure zhongwenfind (@mingzi nvarchar(10)) AS SELECT mingzi FROM zhongwen WHERE mingzi = @mingzi go exec zhongwenfind N'李杰' go drop table zhongwen go drop procedure zhongwenfind go 

When I run this code in MS SQL 2008 Express, the results display only a few thin boxes. If I copy a set of thin boxes and paste them here (stack overflow asks textarea), they appear as the correct characters (here I go: 空 炮 鸡蛋). Is it possible to install MS SQL 2008 Express to display them correctly?

More importantly, when I run my PHP site, which ultimately needs to display characters correctly for the public, I only get question marks (????). I am using mssql_query() to query the db. I have the following code at the top of my HTML5 HEAD:

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 

... and the following code in my PHP:

 header('Content-Type:text/html; charset=UTF-8'); 

... but I only see question marks. So, to summarize, 2 questions:

1) How to display this screen in MS SQL 2008 Express?

2) How to display this screen in PHP / HTML?

Thanks in advance!

+8
php sql-server-2008 utf-8 character-encoding collation
source share
2 answers

I had the same problem in my application, although I used accented characters (getting ???) and I resolved it by changing the encoding of the database, tables and text fields to utf8_unicode_ci along with the file encodings. If you are working on a real server, before converting, please backup db. Also, save the text field data in blob before updating the table and sorting the fields.

Hope this helps!

0
source share

I had a similar requirement, I was able to solve this and was able to show Korean and Japanese [SQL Server 2008 R2 Express and HTML + ASP.NET]

  • Use SQL_Latin1_General_CP1_CI_AS to map the database in SQL Server

  • When deploying your code to a server / machine, make sure the HTML files are saved as UTF-8 . Encoding (To check this, open the file> Save As> check the encoding)

0
source share

All Articles