<div dir="ltr">+1 Makes sense, it's a basic failable conversion.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 22, 2016 at 2:09 PM, 王 黎明 <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
+0.
<div><br>
<div>Maybe off topic.</div>
<div><br>
<div>The problem is there’s no process for the validty of the parameter.</div>
<div><br>
</div>
<div>The source of UnicodeScala:</div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div><font color="#000000"> public init(_ v: UInt32) {</font></div>
<div><font color="#000000"> // Unicode 6.3.0:</font></div>
<div><font color="#000000"> //</font></div>
<div><font color="#000000"> // D9. Unicode codespace: A range of integers from 0 to 10FFFF.</font></div>
<div><font color="#000000"> //</font></div>
<div><font color="#000000"> // D76. Unicode scalar value: Any Unicode code point except</font></div>
<div><font color="#000000"> // high-surrogate and low-surrogate code points.</font></div>
<div><font color="#000000"> //</font></div>
<div><font color="#000000"> // * As a result of this definition, the set of Unicode scalar values</font></div>
<div><font color="#000000"> // consists of the ranges 0 to D7FF and E000 to 10FFFF, inclusive.</font></div>
<div><font color="#000000"><br>
</font></div>
<div><font color="#000000"> _precondition(v < 0xD800 || v > 0xDFFF,</font></div>
<div><font color="#000000"> "high- and low-surrogate code points are not valid Unicode scalar values")</font></div>
<div><font color="#000000"> _precondition(v <= 0x10FFFF, "value is outside of Unicode codespace")</font></div>
<div><font color="#000000"><br>
</font></div>
<div><font color="#000000"> self._value = v</font></div>
<div><font color="#000000"> }</font></div>
</blockquote>
<div><br>
</div>
<div>55357 == 0xD83D , not less than 0xD800</div>
<div><br>
</div>
<div>The _precondition like assert. </div><div><div class="h5">
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<br>
<blockquote type="cite">
<div>在 2016年7月22日,上午10:23,Karl via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> 写道:</div>
<br>
<div>
<div>+1. I was trying to build a naive random string generator the other day (but I wanted it to occasionally spit out extended clusters like emojis), and was also surprised that the initialiser crashes.<br>
<br>
Could probably be filed under “bug fixes”, even.<br>
<br>
Karl<br>
<br>
<blockquote type="cite">On 22 Jul 2016, at 00:28, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
<br>
Hello Swift community,<br>
<br>
The review of "SE-0128: Change failable UnicodeScalar initializers to failable" begins now and runs through July 24. The proposal is available here:<br>
<br>
<span style="white-space:pre-wrap"></span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0128-unicodescalar-failable-initializer.md" target="_blank">https://github.com/apple/swift-evolution/blob/master/proposals/0128-unicodescalar-failable-initializer.md</a><br>
<br>
Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at<br>
<br>
<span style="white-space:pre-wrap"></span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
or, if you would like to keep your feedback private, directly to the review manager.<br>
<br>
What goes into a review?<br>
<br>
The goal of the review process is to improve the proposal under review through constructive criticism and contribute to the direction of Swift. When writing your review, here are some questions you might want to answer in your review:<br>
<br>
<span style="white-space:pre-wrap"></span>* What is your evaluation of the proposal?<br>
<span style="white-space:pre-wrap"></span>* Is the problem being addressed significant enough to warrant a change to Swift?<br>
<span style="white-space:pre-wrap"></span>* Does this proposal fit well with the feel and direction of Swift?<br>
<span style="white-space:pre-wrap"></span>* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br>
<span style="white-space:pre-wrap"></span>* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br>
<br>
More information about the Swift evolution process is available at<br>
<br>
<span style="white-space:pre-wrap"></span><a href="https://github.com/apple/swift-evolution/blob/master/process.md" target="_blank">https://github.com/apple/swift-evolution/blob/master/process.md</a><br>
<br>
Thank you,<br>
<br>
-Chris Lattner<br>
Review Manager<br>
<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div>
</div>
</blockquote>
</div></div></div>
<br>
</div>
</div>
</div>
</div>
<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>
<br></blockquote></div><br></div>