@@ -116,9 +116,9 @@ Goals
116
116
``String `` should:
117
117
118
118
* honor industry standards such as Unicode
119
- * when handling non-ASCII text, deliver “ reasonably correct”
119
+ * when handling non-ASCII text, deliver " reasonably correct"
120
120
results to users thinking only in terms of ASCII
121
- * when handling ASCII text, provide “ expected behavior” to users
121
+ * when handling ASCII text, provide " expected behavior" to users
122
122
thinking only in terms of ASCII
123
123
* be hard to use incorrectly
124
124
* be easy to use correctly
@@ -165,7 +165,7 @@ optimizations, including:
165
165
- In-place modification of uniquely-owned buffers
166
166
167
167
As a result, copying _ and slicing __ strings, in particular, can be
168
- viewed by most programmers as being “ almost free.”
168
+ viewed by most programmers as being " almost free."
169
169
170
170
__ sliceable _
171
171
@@ -197,7 +197,7 @@ Strings are **Value Types**
197
197
Distinct string variables have independent values: when you pass
198
198
someone a string they get a copy of the value, and when someone
199
199
passes you a string *you own it *. Nobody can change a string value
200
- “ behind your back.”
200
+ " behind your back."
201
201
202
202
.. parsed-literal ::
203
203
|swift | class Cave {
@@ -231,18 +231,18 @@ Strings are **Unicode-Aware**
231
231
specifies requires careful justification. So far, we have found two
232
232
possible points of deviation for Swift ``String ``:
233
233
234
- 1. The `Unicode Text Segmentation Specification `_ says, “ `do not
235
- break between CR and LF `__.” However, breaking extended
234
+ 1. The `Unicode Text Segmentation Specification `_ says, " `do not
235
+ break between CR and LF `__." However, breaking extended
236
236
grapheme clusters between CR and LF may necessary if we wish
237
- ``String `` to “ behave normally” for users of pure ASCII. This
237
+ ``String `` to " behave normally" for users of pure ASCII. This
238
238
point is still open for discussion.
239
239
240
240
__ http://www.unicode.org/reports/tr29/#GB2
241
241
242
242
2. The `Unicode Text Segmentation Specification `_ says,
243
- “ `do not break between regional indicator symbols `__.” However, it also
244
- says “ (Sequences of more than two RI characters should be separated
245
- by other characters, such as U+200B ZWSP).” Although the
243
+ " `do not break between regional indicator symbols `__." However, it also
244
+ says " (Sequences of more than two RI characters should be separated
245
+ by other characters, such as U+200B ZWSP)." Although the
246
246
parenthesized note probably has less official weight than the other
247
247
admonition, breaking pairs of RI characters seems like the right
248
248
thing for us to do given that Cocoa already forms strings with
@@ -278,7 +278,7 @@ Strings are **Locale-Agnostic**
278
278
279
279
Strings neither carry their own locale information, nor provide
280
280
behaviors that depend on a global locale setting. Thus, for any pair
281
- of strings ``s1 `` and ``s2 ``, “ ``s1 == s2 ``” yields the same result
281
+ of strings ``s1 `` and ``s2 ``, " ``s1 == s2 ``" yields the same result
282
282
regardless of system state. Strings *do * provide a suitable
283
283
foundation on which to build locale-aware interfaces.\ [#locales ]_
284
284
@@ -316,8 +316,8 @@ Strings are Composed of ``Character``\ s
316
316
cluster **, as specified by a default or tailored Unicode segmentation
317
317
algorithm. This term is `precisely defined `__ by the Unicode
318
318
specification, but it roughly means `what the user thinks of when she
319
- hears “ character” `__. For example, the pair of code points “ LATIN
320
- SMALL LETTER N, COMBINING TILDE” forms a single grapheme cluster, “ñ” .
319
+ hears " character" `__. For example, the pair of code points " LATIN
320
+ SMALL LETTER N, COMBINING TILDE" forms a single grapheme cluster, "ñ" .
321
321
322
322
__ http://www.unicode.org/glossary/#grapheme_cluster
323
323
__ http://useless-factor.blogspot.com/2007/08/unicode-implementers-guide-part-4.html
@@ -342,8 +342,8 @@ __ http://www.unicode.org/glossary/#extended_grapheme_cluster
342
342
__ http://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table
343
343
344
344
This segmentation offers naïve users of English, Chinese, French, and
345
- probably a few other languages what we think of as the “ expected
346
- results.” However, not every script _ can be segmented uniformly for
345
+ probably a few other languages what we think of as the " expected
346
+ results." However, not every script _ can be segmented uniformly for
347
347
all purposes. For example, searching and collation require different
348
348
segmentations in order to handle Indic scripts correctly. To that
349
349
end, strings support properties for more-specific segmentations:
@@ -386,9 +386,9 @@ Strings are **Sliceable**
386
386
.. parsed-literal ::
387
387
|swift | s[r.start...r.end]
388
388
`// r2 : String = "awe" `
389
- |swift | s[\ :look1: `r.start... `\ ]\ :aside: `postfix slice operator means “ through the end” `
389
+ |swift | s[\ :look1: `r.start... `\ ]\ :aside: `postfix slice operator means " through the end" `
390
390
`// r3 : String = "awesome" `
391
- |swift | s[\ :look1: `...r.start `\ ]\ :aside: `prefix slice operator means “ from the beginning” `
391
+ |swift | s[\ :look1: `...r.start `\ ]\ :aside: `prefix slice operator means " from the beginning" `
392
392
`// r4 : String = "Strings are " `
393
393
|swift | :look1: `s[r] `\ :aside: `indexing with a range is the same as slicing `
394
394
`// r5 : String = "awe" `
@@ -579,7 +579,7 @@ How Would You Design It?
579
579
5. CodePoint substring search is just byte string search
580
580
6. Most programs that handle 8-bit files safely can handle UTF-8 safely
581
581
7. UTF-8 sequences sort in code point order.
582
- 8. UTF-8 has no “ byte order.”
582
+ 8. UTF-8 has no " byte order."
583
583
584
584
__ http://research.swtch.com/2010/03/utf-8-bits-bytes-and-benefits.html
585
585
@@ -682,7 +682,7 @@ withRange:subrange]`` becomes ``str[subrange].doFoo(arg)``.
682
682
683
683
* Deprecated Cocoa APIs are not considered
684
684
685
- * A status of “ *Remove *” below indicates a feature whose removal is
685
+ * A status of " *Remove *" below indicates a feature whose removal is
686
686
anticipated. Rationale is provided for these cases.
687
687
688
688
Indexing
@@ -806,18 +806,18 @@ Comparison
806
806
func **<= ** (lhs: String, rhs: String) -> Bool
807
807
func **>= ** (lhs: String, rhs: String) -> Bool
808
808
809
- ``NSString `` comparison is “ literal” by default. As the documentation
809
+ ``NSString `` comparison is " literal" by default. As the documentation
810
810
says of ``isEqualToString ``,
811
811
812
- “Ö” represented as the composed character sequence “O” and umlaut
813
- would not compare equal to “Ö” represented as one Unicode character.
812
+ "Ö" represented as the composed character sequence "O" and umlaut
813
+ would not compare equal to "Ö" represented as one Unicode character.
814
814
815
815
By contrast, Swift string's primary comparison interface uses
816
816
Unicode's default collation _ algorithm, and is thus always
817
- “ Unicode-correct.” Unlike comparisons that depend on locale, it is
817
+ " Unicode-correct." Unlike comparisons that depend on locale, it is
818
818
also stable across changes in system state. However, *just like *
819
819
``NSString ``\ 's ``isEqualToString `` and ``compare `` methods, it
820
- should not be expected to yield ideal (or even “ proper” ) results in
820
+ should not be expected to yield ideal (or even " proper" ) results in
821
821
all contexts.
822
822
823
823
---------
@@ -1084,10 +1084,10 @@ Capitalization
1084
1084
1085
1085
.. Note :: ``NSString`` capitalizes the first letter of each substring
1086
1086
separated by spaces, tabs, or line terminators, which is in
1087
- no sense “ Unicode-correct.” In most other languages that
1087
+ no sense " Unicode-correct." In most other languages that
1088
1088
support a ``capitalize `` method, it operates only on the
1089
1089
first character of the string, and capitalization-by-word is
1090
- named something like “ ``title ``.” If Swift ``String ``
1090
+ named something like " ``title ``." If Swift ``String ``
1091
1091
supports capitalization by word, it should be
1092
1092
Unicode-correct, but how we sort this particular area out is
1093
1093
still **TBD **.
@@ -1712,7 +1712,7 @@ Why YAGNI
1712
1712
* Derivation
1713
1713
* ...
1714
1714
1715
- .. [#agnostic ] Unicode specifies default (“ un-tailored” )
1715
+ .. [#agnostic ] Unicode specifies default (" un-tailored" )
1716
1716
locale-independent collation _ and segmentation _ algorithms that
1717
1717
make reasonable sense in most contexts. Using these algorithms
1718
1718
allows strings to be naturally compared and combined, generating
@@ -1748,6 +1748,6 @@ Why YAGNI
1748
1748
been normalized, thus speeding up comparison operations.
1749
1749
1750
1750
.. [#elements ] Since ``String `` is locale-agnostic _, its elements are
1751
- determined using Unicode's default, “ un-tailored” segmentation _
1751
+ determined using Unicode's default, " un-tailored" segmentation _
1752
1752
algorithm.
1753
1753
0 commit comments