2016-08-20 25 views
-1

当我想打印出字形簇其中从U + 0021以U + 0100以Unicode表的代码点错误打印Unicode字形集群由for循环

for i in 21...100 { 
    print("\u{i} ", terminator: "") 
} 

编译器呈现我以下错误

enter image description here

问题:我想我不能用指数从for循环数组作为字符串解释Unicode标指标。如果是这样,我应该改变使用循环正确

非常感谢

+0

我不知道SWIFT所以这可能是完全错误的,但你需要从int到字符铸。 – Casey

+0

当我在21 ... 21'时,你期望输出什么? – OOPer

+1

查看http://stackoverflow.com/questions/25799413/converting-to-char-string-from-ascii-int-in-swift或甚至http://stackoverflow.com/questions/34259425/how-to-convert -an-int-a-character-in-swift –

回答

1

\u{n}特殊字符只能与一个文字十六进制数n什么步骤。 但是你可以从其数值创造一个Unicode标:

for i in 0x21...0x100 { 
    print(UnicodeScalar(i), terminator: "") 
} 
+0

非常感谢Martin – SLN