[swift-evolution] Proposal: Make it easier to use unicode identifiers in Swift.
肇鑫
owenzx at gmail.com
Thu Jan 14 20:33:53 CST 2016
let unicodeScalar = UnicodeScalar("α") // 945
unicodeScalar.dynamicType // UnicodeScalar.Type
var unicodeScalars = "This is α".unicodeScalars // "This is α"
unicodeScalars.dynamicType // String.UnicodeScalarView.Type
let u1 = unicodeScalars.last! // 945
u1.dynamicType // UnicodeScalar.Type
let values = unicodeScalars.map({ $0.value })
values // [84, 104, 105, 115, 32, 105, 115, 32, 945]
values.dynamicType // Array<UInt32>.Type
let range = Range(start: unicodeScalars.endIndex.predecessor(), end:
unicodeScalars.endIndex)
let beta = UnicodeScalar(unicodeScalar.value + 1) // 946
unicodeScalars.replaceRange(range, with: [beta])
unicodeScalars // "This is β"
zhaoxin
On Fri, Jan 15, 2016 at 7:34 AM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:
> In particular, allow the programmer to use text instead of unicode when
> convenient.
>
> For example:
>
> unicodealias alpha = α
>
> let alpha = 5.0
>
> print("α=\(α)”)
>
> Every once in a while, the programmer could request that the IDE/editor
> transform the text names to their unicode counterparts as determined by
> unicode aliases throughout the source.
>
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
--
Owen Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160115/473158d0/attachment-0001.html>
More information about the swift-evolution
mailing list