Expected hexadecimal code in braces after unicode

2019-01-26 03:04发布

问题:

This worked in the first beta of Swift.

var degree = "\u00B0" // degree symbol

Now I'm getting this error and I don't understand what I need to do to correct it in Xcode 6 Beta 5.

Expected hexadecimal code in braces after unicode escape

回答1:

The correct code is:

var degree = "\u{00B0}" // degree symbol

From the Xcode 6 beta 4 release notes:

The \x, \u and \U escape sequences in string literals have been consolidated into a single and less error prone \u{123456} syntax. (17279286)



标签: swift xcode6