C 17提出的UTF-8字元文字的要點是什麼?
提出的這點是甚麼呢?
它們的唯一功能似乎是防止擴充套件的ASCII字元或部分UTF-8程式碼點被指定.他們仍然儲存在一個固定寬度的8位字元(根據我的理解,這是處理UTF-8的正確和最好的方法幾乎所有用例),所以他們不支援非ASCII字元所有.到底是怎麼回事?
(實際上,我並不完全相信我也理解UTF-8字串文字的需要,我想這是編譯器用Unicode字串加上Unicode的驗證做奇怪/含糊的事情的擔心嗎?)
We have five encoding-prefixes for string-literals (none, L, u8, u, U)but only four for character literals — the missing one is u8 forcharacter literals. This matters for implementations where the narrow execution characterset is not ASCII. In such a case, u8 character literals would providean ideal way to write character literals with guaranteed ASCIIencoding (the single-code-unit u8 encodings are exactly ASCII), but…we don’t provide them. Instead, the best one can do is something like this: 06000 … where we’ll get a narrowing error if the codepoint doesn’t fit ina ‘char’. (Note that this is not quite the same as u8’x’, which wouldgive us an error if the codepoint was not representable as a singlecode unit in UTF-8.)
程式碼日誌版權宣告:
翻譯自:http://stackoverflow.com/questions/31970111/what-is-the-point-of-the-utf-8-character-literals-proposed-for-c17