简体   繁体   中英

Unicode string in C#

I remember using Unicode string in C++ such as this:

std::wstring str = _T("a string here");

What is the equivalent in C#?

The equivalent in C# is the String class.

According to MSDN :

(A String) Represents text as a series of Unicode characters.

[...] Each code point is encoded using UTF-16 encoding

So, if you do string str = "a string here"; , you have a Unicode string.

Use System.Text.UnicodeEncoding class. This handles UTF-16 encoding of Unicode characters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM