What must be considered for storing strings of different languages in a sql server database?
Background:
For various reasons I'm creating a translation table in my sql server 2008 r2. (This question is not about whether that is a correct / good choice)
This table should store translation for languages like english, german, french. Languages like japanese or chinese might fo开发者_StackOverflow中文版llow shortly.The table is filled/update by a WinForms application and later shown to customers in an ASP.Net WebApplication.
I'm using the Entity Framework 4 with the Models first (creating entities in the designer to create an create script afterwards)
Now to the question:
How do I ensure the correct encoding for the save and read operations in the WinForms and the ASP.Net applications? How must the columnTypes in the database look like?
EntityFramework Designer
Apparently I can only use "String" as ColumnType in the EntitityDesigner. Chosing "String" in the designer will translate to nvarchar(max). Is that the correct columnType to store strings of different languages?
ConnectionString
I guess adding Charset=utf8; to the connectionString is also necessary.
ASP.Net
Setting utf-8 as output type in the ASP.Net application seems logic to me.
WinForms
Must I set anything else in the WinForms application? Do I need to call some encoding / decoding methods myself? If yes, which one and why?
Have I missed something? Do I need to configure something else?
nvarchar is correct. It stores data in unicode and you do not need to encode/decode anything if you are using utf-8 in your application.
精彩评论