<div dir="ltr"><div class="gmail_default"><div class="gmail_default"><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> unicodeScalar = <span style="color:rgb(112,61,170)">UnicodeScalar</span>(<span style="color:rgb(209,47,27)">&quot;α&quot;</span>) <span style="color:rgb(0,132,0)">// 945</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(79,129,135)">unicodeScalar</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(187,44,162)">dynamicType</span><span style="color:rgb(0,0,0)"> </span>// UnicodeScalar.Type</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">var</span> unicodeScalars = <span style="color:rgb(209,47,27)">&quot;This is α&quot;</span>.<span style="color:rgb(112,61,170)">unicodeScalars</span> <span style="color:rgb(0,132,0)">// &quot;This is α&quot;</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(79,129,135)">unicodeScalars</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(187,44,162)">dynamicType</span><span style="color:rgb(0,0,0)"> </span>// String.UnicodeScalarView.Type</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)"><span style="color:rgb(187,44,162)">let</span><span style="color:rgb(0,0,0)"> u1 = </span>unicodeScalars<span style="color:rgb(0,0,0)">.</span><span style="color:rgb(112,61,170)">last</span><span style="color:rgb(0,0,0)">! </span><span style="color:rgb(0,132,0)">// 945</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(79,129,135)">u1</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(187,44,162)">dynamicType</span><span style="color:rgb(0,0,0)"> </span>// UnicodeScalar.Type</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> values = <span style="color:rgb(79,129,135)">unicodeScalars</span>.<span style="color:rgb(61,29,129)">map</span>({ $0.<span style="color:rgb(112,61,170)">value</span> })</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(79,129,135)">values</span><span style="color:rgb(0,0,0)"> </span>// [84, 104, 105, 115, 32, 105, 115, 32, 945]</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(79,129,135)">values</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(187,44,162)">dynamicType</span><span style="color:rgb(0,0,0)"> </span>// Array&lt;UInt32&gt;.Type</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">let</span> range = <span style="color:rgb(112,61,170)">Range</span>(start: <span style="color:rgb(79,129,135)">unicodeScalars</span>.<span style="color:rgb(112,61,170)">endIndex</span>.<span style="color:rgb(61,29,129)">predecessor</span>(), end: <span style="color:rgb(79,129,135)">unicodeScalars</span>.<span style="color:rgb(112,61,170)">endIndex</span>)</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><span style="color:rgb(187,44,162)">let</span><span style="color:rgb(0,0,0)"> beta = </span>UnicodeScalar<span style="color:rgb(0,0,0)">(</span><span style="color:rgb(79,129,135)">unicodeScalar</span><span style="color:rgb(0,0,0)">.</span>value<span style="color:rgb(0,0,0)"> + </span><span style="color:rgb(39,42,216)">1</span><span style="color:rgb(0,0,0)">) </span><span style="color:rgb(0,132,0)">// </span><span style="color:rgb(0,132,0)">946</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">unicodeScalars<span style="color:rgb(0,0,0)">.</span><span style="color:rgb(61,29,129)">replaceRange</span><span style="color:rgb(0,0,0)">(</span>range<span style="color:rgb(0,0,0)">, with: [</span>beta<span style="color:rgb(0,0,0)">])</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)">unicodeScalars<span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,132,0)">// &quot;This is β&quot;</span></p></div></div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 15, 2016 at 7:34 AM, Amir Michail via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">In particular, allow the programmer to use text instead of unicode when convenient.<br>
<br>
For example:<br>
<br>
unicodealias alpha = α<br>
<br>
let alpha = 5.0<br>
<br>
print(&quot;α=\(α)”)<br>
<br>
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.<br>
<br>
<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><br>Owen Zhao<br></div></div></div>
</div>