If I persist a windows-1252 string (e.g. something with “smart quotes”) from C# to a record into a SQLServer db, is the encoding preserved if I read it back out into another string variable?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, no or maybe.
Each VARCHAR column in SQL Server has a “collation”, roughly equivalent to a codepage (character set) plus a sort order.
If the codepage of the collation can store all the characters in the string they should round-trip properly. If not, not.
If your collation is a variant of
Latin1_Generalyou should be able to store the whole windows-1252 character set.For more, see here:
http://msdn.microsoft.com/en-us/library/ms188046.aspx
Note that if you haven’t set a collation on the field, it will use the database’s default collation, which is usually
Latin1_General_CI_AS.It is important to be aware of character set issues. If you need to store characters in one field which cannot all be fitted into the same codepage you need to use NVARCHAR. In an NVARCHAR field, all characters can be stored and the collation only controls the sort order and equality comparisions.