Display unicode chars in VB.NET
I can't manage to display unicode characters in VB.NET.
I'm doing this in C#: string 开发者_如何转开发myString = "\u03A3"; //upper case sigma (sum)
But it doesn't work in VB and I can't find a way to make it work.
Visual Studio source files are already unicode enabled. In most cases, you can put the unicode character you want right in the source. But failing that, try the ChrW()
function.
In VB it's slightly different; use the following line instead:
myString = Convert.ToChar(&H3A3)
Good luck.
Unlike C#, the only string escape sequence in VB.Net is that two contiguous quotation marks are replaced with a single quotation mark. Escapes like \t
, \n
and \uXXXX
don't exist in VB. As @Tim Schmelter and @Joel Coehoorn pointed out, Unicode symbols are completely valid in VB.Net source files so there is no need to escape them unless you are storing files as ASCII. If you have a need to use escape sequences you can use the static System.Text.RegularExpressions.Regex.Unescape(string)
method which should do most C# escape sequences.
精彩评论