<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">Hi Brent,</p>
<p dir="auto">Perhaps the wording would be better phrased as "boundary from non-uppercase-character to uppercase-character", i.e. numbers and Emoji are treated the same as lowercase characters and are included in the original word.<br>
The following are <a href="https://github.com/apple/swift/pull/12779/files#diff-26b09c16508c21f9f59dcf6c7a41d4b4R422" style="color:#3983C4">unit test cases from the associated PR</a>, which should indicate the behavior implemented here:</p>
<pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px; color:black" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7"><span style="color: #008800; font-weight: bold">let</span> <span style="color: #996633">toSnakeCaseTests</span> = [
(<span style="background-color: #fff0f0">"simpleOneTwo"</span>, <span style="background-color: #fff0f0">"simple_one_two"</span>),
(<span style="background-color: #fff0f0">"myURL"</span>, <span style="background-color: #fff0f0">"my_url"</span>),
(<span style="background-color: #fff0f0">"singleCharacterAtEndX"</span>, <span style="background-color: #fff0f0">"single_character_at_end_x"</span>),
(<span style="background-color: #fff0f0">"thisIsAnXMLProperty"</span>, <span style="background-color: #fff0f0">"this_is_an_xml_property"</span>),
(<span style="background-color: #fff0f0">"single"</span>, <span style="background-color: #fff0f0">"single"</span>), <span style="color: #888888">// no underscore</span>
(<span style="background-color: #fff0f0">""</span>, <span style="background-color: #fff0f0">""</span>), <span style="color: #888888">// don't die on empty string</span>
(<span style="background-color: #fff0f0">"a"</span>, <span style="background-color: #fff0f0">"a"</span>), <span style="color: #888888">// single character</span>
(<span style="background-color: #fff0f0">"aA"</span>, <span style="background-color: #fff0f0">"a_a"</span>), <span style="color: #888888">// two characters</span>
(<span style="background-color: #fff0f0">"version4Thing"</span>, <span style="background-color: #fff0f0">"version4_thing"</span>), <span style="color: #888888">// numerics</span>
(<span style="background-color: #fff0f0">"partCAPS"</span>, <span style="background-color: #fff0f0">"part_caps"</span>), <span style="color: #888888">// only insert underscore before first all caps</span>
(<span style="background-color: #fff0f0">"partCAPSLowerAGAIN"</span>, <span style="background-color: #fff0f0">"part_caps_lower_again"</span>), <span style="color: #888888">// switch back and forth caps.</span>
(<span style="background-color: #fff0f0">"manyWordsInThisThing"</span>, <span style="background-color: #fff0f0">"many_words_in_this_thing"</span>), <span style="color: #888888">// simple lowercase underscore more</span>
(<span style="background-color: #fff0f0">"asdfĆqer"</span>, <span style="background-color: #fff0f0">"asdf_ćqer"</span>),
(<span style="background-color: #fff0f0">"already_snake_case"</span>, <span style="background-color: #fff0f0">"already_snake_case"</span>),
(<span style="background-color: #fff0f0">"dataPoint22"</span>, <span style="background-color: #fff0f0">"data_point22"</span>),
(<span style="background-color: #fff0f0">"dataPoint22Word"</span>, <span style="background-color: #fff0f0">"data_point22_word"</span>),
(<span style="background-color: #fff0f0">"_oneTwoThree"</span>, <span style="background-color: #fff0f0">"_one_two_three"</span>),
(<span style="background-color: #fff0f0">"oneTwoThree_"</span>, <span style="background-color: #fff0f0">"one_two_three_"</span>),
(<span style="background-color: #fff0f0">"__oneTwoThree"</span>, <span style="background-color: #fff0f0">"__one_two_three"</span>),
(<span style="background-color: #fff0f0">"oneTwoThree__"</span>, <span style="background-color: #fff0f0">"one_two_three__"</span>),
(<span style="background-color: #fff0f0">"_oneTwoThree_"</span>, <span style="background-color: #fff0f0">"_one_two_three_"</span>),
(<span style="background-color: #fff0f0">"__oneTwoThree"</span>, <span style="background-color: #fff0f0">"__one_two_three"</span>),
(<span style="background-color: #fff0f0">"__oneTwoThree__"</span>, <span style="background-color: #fff0f0">"__one_two_three__"</span>),
(<span style="background-color: #fff0f0">"_test"</span>, <span style="background-color: #fff0f0">"_test"</span>),
(<span style="background-color: #fff0f0">"_test_"</span>, <span style="background-color: #fff0f0">"_test_"</span>),
(<span style="background-color: #fff0f0">"__test"</span>, <span style="background-color: #fff0f0">"__test"</span>),
(<span style="background-color: #fff0f0">"test__"</span>, <span style="background-color: #fff0f0">"test__"</span>),
(<span style="background-color: #fff0f0">"m͉̟̹y̦̳G͍͚͎̳r̤͉̤͕ͅea̲͕t͇̥̼͖U͇̝̠R͙̻̥͓̣L̥̖͎͓̪̫ͅR̩͖̩eq͈͓u̞e̱s̙t̤̺ͅ"</span>, <span style="background-color: #fff0f0">"m͉̟̹y̦̳_g͍͚͎̳r̤͉̤͕ͅea̲͕t͇̥̼͖_u͇̝̠r͙̻̥͓̣l̥̖͎͓̪̫ͅ_r̩͖̩eq͈͓u̞e̱s̙t̤̺ͅ"</span>), <span style="color: #888888">// because Itai wanted to test this</span>
(<span style="background-color: #fff0f0">"🐧🐟"</span>, <span style="background-color: #fff0f0">"🐧🐟"</span>) <span style="color: #888888">// fishy emoji example?</span>
]
</code></pre>
<p dir="auto">And for completeness, the <a href="https://github.com/apple/swift/pull/12779/files#diff-26b09c16508c21f9f59dcf6c7a41d4b4R540" style="color:#3983C4">complementary test cases</a>:</p>
<pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px; color:black" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7"><span style="color: #008800; font-weight: bold">let</span> <span style="color: #996633">fromSnakeCaseTests</span> = [
(<span style="background-color: #fff0f0">""</span>, <span style="background-color: #fff0f0">""</span>), <span style="color: #888888">// don't die on empty string</span>
(<span style="background-color: #fff0f0">"a"</span>, <span style="background-color: #fff0f0">"a"</span>), <span style="color: #888888">// single character</span>
(<span style="background-color: #fff0f0">"ALLCAPS"</span>, <span style="background-color: #fff0f0">"ALLCAPS"</span>), <span style="color: #888888">// If no underscores, we leave the word as-is</span>
(<span style="background-color: #fff0f0">"ALL_CAPS"</span>, <span style="background-color: #fff0f0">"allCaps"</span>), <span style="color: #888888">// Conversion from screaming snake case</span>
(<span style="background-color: #fff0f0">"single"</span>, <span style="background-color: #fff0f0">"single"</span>), <span style="color: #888888">// do not capitalize anything with no underscore</span>
(<span style="background-color: #fff0f0">"snake_case"</span>, <span style="background-color: #fff0f0">"snakeCase"</span>), <span style="color: #888888">// capitalize a character</span>
(<span style="background-color: #fff0f0">"one_two_three"</span>, <span style="background-color: #fff0f0">"oneTwoThree"</span>), <span style="color: #888888">// more than one word</span>
(<span style="background-color: #fff0f0">"one_2_three"</span>, <span style="background-color: #fff0f0">"one2Three"</span>), <span style="color: #888888">// numerics</span>
(<span style="background-color: #fff0f0">"one2_three"</span>, <span style="background-color: #fff0f0">"one2Three"</span>), <span style="color: #888888">// numerics, part 2</span>
(<span style="background-color: #fff0f0">"snake_Ćase"</span>, <span style="background-color: #fff0f0">"snakeĆase"</span>), <span style="color: #888888">// do not further modify a capitalized diacritic</span>
(<span style="background-color: #fff0f0">"snake_ćase"</span>, <span style="background-color: #fff0f0">"snakeĆase"</span>), <span style="color: #888888">// capitalize a diacritic</span>
(<span style="background-color: #fff0f0">"alreadyCamelCase"</span>, <span style="background-color: #fff0f0">"alreadyCamelCase"</span>), <span style="color: #888888">// do not modify already camel case</span>
(<span style="background-color: #fff0f0">"__this_and_that"</span>, <span style="background-color: #fff0f0">"__thisAndThat"</span>),
(<span style="background-color: #fff0f0">"_this_and_that"</span>, <span style="background-color: #fff0f0">"_thisAndThat"</span>),
(<span style="background-color: #fff0f0">"this__and__that"</span>, <span style="background-color: #fff0f0">"thisAndThat"</span>),
(<span style="background-color: #fff0f0">"this_and_that__"</span>, <span style="background-color: #fff0f0">"thisAndThat__"</span>),
(<span style="background-color: #fff0f0">"this_aNd_that"</span>, <span style="background-color: #fff0f0">"thisAndThat"</span>),
(<span style="background-color: #fff0f0">"_one_two_three"</span>, <span style="background-color: #fff0f0">"_oneTwoThree"</span>),
(<span style="background-color: #fff0f0">"one_two_three_"</span>, <span style="background-color: #fff0f0">"oneTwoThree_"</span>),
(<span style="background-color: #fff0f0">"__one_two_three"</span>, <span style="background-color: #fff0f0">"__oneTwoThree"</span>),
(<span style="background-color: #fff0f0">"one_two_three__"</span>, <span style="background-color: #fff0f0">"oneTwoThree__"</span>),
(<span style="background-color: #fff0f0">"_one_two_three_"</span>, <span style="background-color: #fff0f0">"_oneTwoThree_"</span>),
(<span style="background-color: #fff0f0">"__one_two_three"</span>, <span style="background-color: #fff0f0">"__oneTwoThree"</span>),
(<span style="background-color: #fff0f0">"__one_two_three__"</span>, <span style="background-color: #fff0f0">"__oneTwoThree__"</span>),
(<span style="background-color: #fff0f0">"_test"</span>, <span style="background-color: #fff0f0">"_test"</span>),
(<span style="background-color: #fff0f0">"_test_"</span>, <span style="background-color: #fff0f0">"_test_"</span>),
(<span style="background-color: #fff0f0">"__test"</span>, <span style="background-color: #fff0f0">"__test"</span>),
(<span style="background-color: #fff0f0">"test__"</span>, <span style="background-color: #fff0f0">"test__"</span>),
(<span style="background-color: #fff0f0">"_"</span>, <span style="background-color: #fff0f0">"_"</span>),
(<span style="background-color: #fff0f0">"__"</span>, <span style="background-color: #fff0f0">"__"</span>),
(<span style="background-color: #fff0f0">"___"</span>, <span style="background-color: #fff0f0">"___"</span>),
(<span style="background-color: #fff0f0">"m͉̟̹y̦̳G͍͚͎̳r̤͉̤͕ͅea̲͕t͇̥̼͖U͇̝̠R͙̻̥͓̣L̥̖͎͓̪̫ͅR̩͖̩eq͈͓u̞e̱s̙t̤̺ͅ"</span>, <span style="background-color: #fff0f0">"m͉̟̹y̦̳G͍͚͎̳r̤͉̤͕ͅea̲͕t͇̥̼͖U͇̝̠R͙̻̥͓̣L̥̖͎͓̪̫ͅR̩͖̩eq͈͓u̞e̱s̙t̤̺ͅ"</span>), <span style="color: #888888">// because Itai wanted to test this</span>
(<span style="background-color: #fff0f0">"🐧_🐟"</span>, <span style="background-color: #fff0f0">"🐧🐟"</span>) <span style="color: #888888">// fishy emoji example?</span>
]
</code></pre>
<p dir="auto">— Itai</p>
<p dir="auto">On 9 Nov 2017, at 5:57, Brent Royal-Gordon via swift-evolution wrote:</p>
</div>
<div style="white-space:normal"></div>
<blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div id="AB8EA06E-8E8D-4499-81C6-F9AF054B1C91"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Nov 6, 2017, at 12:54 PM, Tony Parker via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Converting from camel case to snake case:</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">1. Splits words at the boundary of lower-case to upper-case</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">2. Inserts `_` between words</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">3. Lowercases the entire string</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">4. Preserves starting and ending `_`.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">For example, `oneTwoThree` becomes `one_two_three`. `_oneTwoThree_` becomes `_one_two_three_`.</div></div></blockquote><br class=""></div><div>My first thought was "are you handling `valueAsHTML` correctly?", but it looks like you are with the "boundary of lower-case to upper-case" wording. But what do you plan to do for numbers? Characters in caseless scripts? Emoji (which are valid in Swift identifiers)? I don't necessarily have strong opinions about the right answer—just want to make sure you do *something* about it.</div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class=""><div style="font-size: 12px; " class="">-- </div><div style="font-size: 12px; " class="">Brent Royal-Gordon</div><div style="font-size: 12px; " class="">Architechies</div></div></span>
</div>
<br class=""></div></div></blockquote>
<div style="white-space:normal">
<blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px">
</blockquote><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">_______________________________________________<br>
swift-evolution mailing list<br>
swift-evolution@swift.org<br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color:#777">https://lists.swift.org/mailman/listinfo/swift-evolution</a></p>
</blockquote></div>
<div style="white-space:normal">
</div>
</div>
</body>
</html>