How to represent Unicode character in VB.Net String literal?

后端 未结 7 1767
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 20:41

I know you can put Unicode character codes in a VB.Net string like this:

str = Chr(&H0030) & \"More text\"

I would like to know how

相关标签:
7条回答
  • 2020-12-03 21:34

    To display an Unicode character, you can use following statement

    1. ChrW(n) where n is the number representing de Unicode character.
    2. Convert.ToChar(n)
    3. type directly character in editor using Alt + N key combination
    4. paste/copy Unicode character directly in editor
    5. Char.ConvertFromUtf32(n)
    6. XML String using &#x....; syntax

    Example to assign ♥ character :

    s = ChrW(&H2665)
    s = Convert.ToChar(&H2665) 
    s = "♥" 'in typing Alt+2665
    s = "♥" 'using paste/copy of ♥ from another location
    s = Char.ConvertFromUtf32(&H2665)
    s = <text>I &#x2665; you</text>
    

    BUT when Unicode Character is greater than 0xFFFF (C syntax is more readable

    0 讨论(0)
提交回复
热议问题