Entity Structure and Preservation of Japanese Text

Can I store English and Japanese in the same field? The field is of type NVARCHAR (1024). The only thing I see is the question marks.

I added another field to the table and set its mapping to japanese. It seems to work. But I do not want 2 columns, I want only 1.

I read throughout that NVARCHAR can store unicode without changing the default collation, is that true, and if so, how can I say EF in English or Japanese?

+4
source share
1 answer

you can check the encryption of the row that you want to save in the database by the entity, and then decide where you save it!

To deal with this problem, I suggest you use the Encoding.GetEncoding (String) method to do this.

Here is the function for you, and you can check it and let me know if it works.

public static bool IsUnicode(string input) { foreach (char chr in input) { string str = chr.ToString(); Encoding code = Encoding.GetEncoding("GB18030"); if (code.GetByteCount(str) == 2) { return false; } } return true; } And here is my test result: string zh = "微软"; string en = "Microsoft"; bool Izh = IsUnicode(zh); //return false bool Ien = IsUnicode(en); //return true 

To the method parameter, you can visit MSDN at http://msdn.microsoft.com/zh-cn/library/aa332097(VS.71).aspx to get the line you need.

Best regards, Nader SGHIR

0
source

Source: https://habr.com/ru/post/1397074/


All Articles