我有一个文本字段输入,返回如下字符串:
let name = "B\U00f6se"
如何转换变音符号,以便\ U00f6(和任何其他特殊字符)被替换为正确的等效字符:
name = "Böse";
感谢您的帮助!
//的Seb
答案 0 :(得分:0)
description
和NSArray
的{{1}}方法使用NSDictionary
所有非ASCII字符的转义序列。
在SwiftForms附带的Xcode示例项目中,提交方法 将此描述显示给用户:
\Unnnn
效果就是你看到了例如
func submit(_: UIBarButtonItem!) {
let message = self.form.formValues().description
let alert: UIAlertView = UIAlertView(title: "Form output", message: message, delegate: nil, cancelButtonTitle: "OK")
alert.show()
}
但lastName = "B\U00f6se";
方法仅适用于调试或记录。
你应该做的是枚举所有的键和值:
description
会告诉你
for (key, value) in self.form.formValues() {
println("\(key) = \(value)")
}
或检索您感兴趣的表单值:
lastName = Böse
答案 1 :(得分:0)