Inserting Unicode Hyphen-minus into String Causes Error

前端 未结 1 566
余生分开走
余生分开走 2021-01-28 09:57

I am trying to insert a unicode hyphen-minus character into a text string. I am seeing an \"Invalid universal character\" error with the following:

u+002D (hyphen-minus)

相关标签:
1条回答
  • 2021-01-28 10:32

    Unversal character names have some restrictions on their use. In C99 and C++98 you were not allowed to use one that referred to a character in the basic character set (which includes U+002D).

    C++11 has updated this requirement so if you are inside a string or character literal then you are allowed to use a UCN that refers to basic characters. Depending on the compiler version you're using I would guess that you could use Objective-C++11 to make your code legal.

    That said, since this character is part of ASCII and the basic character set, why don't you just write it literally?

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