2

I have this problem where I am making a website that displays a news rss feed in Arabic so I insert to sql server database the title, body (description) and the link of each news but they stored in database as (?) symbols so when I request the data from the database to display it in the webpage it displays (?) symbols. How can I make it display the Arabic characters?

I tried

<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

but that was not the solution please any help?!!

Richard Ev
  • 52,939
  • 59
  • 191
  • 278
ra22
  • 133
  • 1
  • 3
  • 7
  • 3
    Is the problem in your database, rather than your website? – Richard Ev Nov 19 '13 at 15:33
  • please explain more how is the problem is in my database? – ra22 Nov 19 '13 at 15:34
  • 1
    I second @RichardEv's comment - specifically, you may be using varchar and not nvarchar field types. See: http://stackoverflow.com/questions/612430/when-must-we-use-nvarchar-nchar-instead-of-varchar-char-in-sql-server – ElHaix Nov 19 '13 at 15:35
  • You said that it's stored as (?) symbols in your database, which suggests that this could be the source of the problem. What database product are you using? – Richard Ev Nov 19 '13 at 15:35
  • @RichardEv iam using sql server 2012 yes it is storing data as symbols and the website that is retrieving the data from (rss and xml) unicode is utf-8 – ra22 Nov 19 '13 at 15:44

2 Answers2

3

Make sure your data type in your database allow insertion of special (eg. Unicode) characters. In Sql Server, as example, you should use nvarchar data type instead of varchar. What is your RDBMS?

LittleSweetSeas
  • 6,786
  • 2
  • 21
  • 26
  • ok sql server problem is solved after altering column datatype to nvarchar and now arabic text is displayed correctly in database but still displaying (?) symbols in my web application how to solve it? – ra22 Nov 19 '13 at 16:55
  • Make sure your text isn't converted to ANSI/UTF-8 characters in any of the steps, from db to web page. A common issue may be the use of db stored procedures/functions to retrieve data, which is casted to varchar – LittleSweetSeas Nov 19 '13 at 16:59
2

Few suggestions:

  • Make sure that the database tables that will store the Arabic data have the proper collation.
    You'll probably need Arabic_CI_AS instead of the default Latin1_General_CI_AS.

  • Make sure that the database columns are set to nvarchar.

  • Make sure that any JavaScripts that are used on your website are saved with UTF8 encoding.

I just bumped into this link in my Smashing Magazine newsletter, it might provide some useful additional info on UTF8 and common difficulties people have with it:
http://the-pastry-box-project.net/oli-studholme/2013-october-8/

Yvo
  • 18,681
  • 11
  • 71
  • 90
  • i altered my columns to nvarchar now the arabic text is displayed correctly in rows but still displaying symbols in my web application what to i have to do? – ra22 Nov 19 '13 at 16:57
  • Make sure that you save your HTML and JavaScript files with UTF8 encoding instead of ASCII. Have a look at the url for more suggestions. – Yvo Nov 19 '13 at 17:00