0

I'm dealing with unicode stuff in my DB. I have a data field defined as varchar(max), and I'm preventing user to save unknown characters in this field, like "≤" for example (all unicode above U+00FF). While doing so, I found that some characters if sent to be saved in this field would be displayed as "?", so I thought that all unicode characters above "U+00FF" will all be displayed like this, but then I found that "U+201B" which is "‛" is displayed "?" but the next character "U+201C" which is "“" is displayed as "“". Can someone please explain to me why is that?

Update: Sorry if I was not clear, but I do not want to convert to nvarchar, I want to keep my field as varchar. What I need to understand is why a character like "‛" is displayed as "?" in a "varchar" field while the next unicode character "“" is displayed properly?

Saleem
  • 709
  • 2
  • 13
  • 34
  • Please read my updated question, sorry about the misunderstanding. – Saleem May 20 '14 at 08:31
  • What do you mean by "displayed"? In what application? – DavidG May 20 '14 at 08:40
  • in the sql server, if I see it in the table or I select and print it. Why sql server does not display it right while a higher unicode can be displayed?! – Saleem May 20 '14 at 08:43
  • Perhaps it's using UTF-8 encoding? – DavidG May 20 '14 at 08:50
  • Yes I think so, but I hoped I'd know how it can do that with a character and not with another one! – Saleem May 20 '14 at 08:51
  • `‘` should be encodable in most ANSI code pages, but if you want other characters like `≤` you have no choice but to use `NVARCHAR`. `VARCHAR` doesn't support Unicode, so whether you want or don't want to change is irrelevant. – bobince May 20 '14 at 12:16
  • I don't know why no one is understanding what my main question is. I know that if I want unicode characters then I'll have to use nvarchar, but I don't want to use unicode characters, I'm forbidding user from entering such characters. My question is (out of curiosity) why a character is displayed wrong (as ?) when a character with higher unicode is displayed right – Saleem May 21 '14 at 13:10

2 Answers2

1

If you want to store Unicode characters, you should use an nvarchar type, not varchar

podiluska
  • 50,950
  • 7
  • 98
  • 104
1

You need to change your data type to nvarchar which will hold any unicode character where varchar is restricted to 8bit codepage.

For more information, read the accepted answer in this link below.

Difference between varchar and nvarchar

Community
  • 1
  • 1
RussellEast
  • 153
  • 8