Skip to content

Commit

Permalink
Add a section on Strings and Unicode
Browse files Browse the repository at this point in the history
I'm not proud of wording but we need clarifications
on this subject.
  • Loading branch information
DmitryOlshansky committed Jul 7, 2013
1 parent 6ebfd1c commit 6dc43ca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
25 changes: 24 additions & 1 deletion arrays.dd
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,28 @@ w = "\r"[0]; // w is assigned the carriage return wchar character
d = 'd'; // d is assigned the character 'd'
---------

$(H5 $(LNAME2 strings_unicode, Strings and Unicode))
$(P Note that built-in comparison operators operate on
$(WEB www.unicode.org/glossary/#code_unit, code unit) basis.
The end result for valid strings is the same as that of
$(WEB www.unicode.org/glossary/#code_point, code point)
for $(WEB www.unicode.org/glossary/#code_point, code point)
comparision as long as both strings are in the same
$(WEB www.unicode.org/glossary/#normalization_form, normalization form).
Since normalization is a costly operation not suitable for language
primitives it's assumed to be enforced by the user.
)
$(P Standard library lends a hand for comparing strings with mixed encodings
(by transparently decoding, see $(PHOBOS algorithm, cmp, std.algorithm.cmp)),
$(PHOBOS uni, icmp, case-insensitive comparision) and $(PHOBOS uni, normalize, normalization).
)
$(P The last but not least - a desired string sorting order differs
by culture and language and is usually nothing like code point
for code point comparison. The natural order of strings is obtained by applying
$(WEB www.unicode.org/reports/tr10/, unicode collation algorithm)
that should be implemented in the standard library.
)

$(H5 $(LNAME2 printf, C's printf() and Strings))

$(P $(D printf()) is a C function and is not part of D. $(D printf())
Expand Down Expand Up @@ -930,4 +952,5 @@ Macros:
WIKI=Arrays
CATEGORY_SPEC=$0
FOO=

WEB=$(LINK2 http://$1, $2)
PHOBOS=<a href="phobos/std_$1.html#$2">$3</a>
1 change: 1 addition & 0 deletions doc.ddoc
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ REG=&copy;
H2=<h2>$0</h2>
H3=<h3>$0</h3>
H4=<h4>$0</h4>
H5=<h5>$0</h5>
CODE_LCURL=$(D {)
CODE_RCURL=$(D })
CODE_PERCENT=$(D %)
Expand Down

0 comments on commit 6dc43ca

Please sign in to comment.