Skip to content

Commit

Permalink
Merge pull request #349 from blackwhale/arrays-page
Browse files Browse the repository at this point in the history
Add a section on Strings and Unicode
  • Loading branch information
andralex committed Jul 8, 2013
2 parents 6ebfd1c + b13bdf8 commit aa27402
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 22 additions & 1 deletion arrays.dd
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 a
$(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)
comparison 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 The 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 comparison) 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/, the 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,3 @@ Macros:
WIKI=Arrays
CATEGORY_SPEC=$0
FOO=

3 changes: 3 additions & 0 deletions doc.ddoc
Expand Up @@ -436,6 +436,8 @@ GLINK2=$(DDSUBLINK $1,$2,$(I $2))
DPLLINK=$(LINK2 $1,$+)
GNAME=$(LNAME2 $0, $(I $0))
NOT_EBOOK=$0
WEB=$(LINK2 http://$1, $2)
PHOBOS=<a href="phobos/std_$1.html#$2">$3</a>

ASSIGNEXPRESSION=$(GLINK2 expression, AssignExpression)
ISEXPRESSION=$(GLINK2 expression, IsExpression)
Expand Down Expand Up @@ -485,6 +487,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 aa27402

Please sign in to comment.