authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-21 17:14:31-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-21 20:31:13-07:00
logf29217ae0c3ddb26f3bb437f26852ffe5f6d1623
tree6ed0ecdf2a076376e20ec92198dda8ba84babc92
parent9be831e15ac28c1e183cebe36e7e1267114efa60

langref: reduce verbosity of string literal section


1 files changed, 7 insertions(+), 18 deletions(-)

doc/langref.html.in+7-18
......@@ -762,30 +762,19 @@ pub fn main() void {
762762 Dereferencing string literals converts them to {#link|Arrays#}.
763763 </p>
764764 <p>
765 The encoding of a string in Zig is de-facto assumed to be UTF-8.
766 Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal
767 in source code carry their UTF-8 meaning into the content of the string in the Zig program;
768 the bytes are not modified by the compiler.
769 However, it is possible to embed non-UTF-8 bytes into a string literal using <code>\xNN</code> notation.
770 </p>
771 <p>
772 Indexing into a string containing non-ASCII bytes will return individual bytes, whether valid
773 UTF-8 or not.
774 The {#link|Zig Standard Library#} provides routines for checking the validity of UTF-8 encoded
775 strings, accessing their code points and other encoding/decoding related tasks in
776 {#syntax#}std.unicode{#endsyntax#}.
765 Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any
766 non-ASCII bytes appearing within a string literal in source code carry
767 their UTF-8 meaning into the content of the string in the Zig program;
768 the bytes are not modified by the compiler. It is possible to embed
769 non-UTF-8 bytes into a string literal using <code>\xNN</code> notation.
777770 </p>
771 <p>Indexing into a string containing non-ASCII bytes returns individual
772 bytes, whether valid UTF-8 or not.</p>
778773 <p>
779774 Unicode code point literals have type {#syntax#}comptime_int{#endsyntax#}, the same as
780775 {#link|Integer Literals#}. All {#link|Escape Sequences#} are valid in both string literals
781776 and Unicode code point literals.
782777 </p>
783 <p>
784 In many other programming languages, a Unicode code point literal is called a "character literal".
785 However, there is <a href="https://unicode.org/glossary">no precise technical definition of a "character"</a>
786 in recent versions of the Unicode specification (as of Unicode 13.0).
787 In Zig, a Unicode code point literal corresponds to the Unicode definition of a code point.
788 </p>
789778 {#code_begin|exe|string_literals#}
790779const print = @import("std").debug.print;
791780const mem = @import("std").mem; // will be used to compare bytes