View Single Post
Old 2016-08-28, 05:29   #1123
Madpoo
Serpentine Vermin Jar
 
Madpoo's Avatar
 
Jul 2014

29·113 Posts
Default

Quote:
Originally Posted by retina View Post
I don't understand the need for 16-bit fields? UTF8 only needs bytes. Browsers submit UTF8 bytes, things are compared as UTF8 bytes, responses are delivered in UTF8 byes. There is no need to convert at any point.
It's a SQL thing... it's about storing in Unicode specifically, not just UTF-8.

I don't know about other SQL servers, but MSSQL stores things in UCS-2, not UTF-8, so if you want more character support you're looking at nvarchar. I guess it could be varbinary too if you didn't mind making the app figure it out that way, but whatever.

Where I always get into trouble with nvarchar is when doing things with static strings, I always seem to forget to use N'string goes here' and use just 'string goes here' without the N, but that's typically also when there's a cast to varbinary in the mix as well.

e.g. cast('string' to varbinary(30)) != cast(N'string' to varbinary(30))
Madpoo is offline   Reply With Quote