authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-21 16:36:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-21 20:31:13-07:00
log6fef362992826cea3fba991ad3d63aaaa59a2385
tree5d64fe5ab76bd243951933f6722849db50929cc8
parent2d9c4792ae2cab0ff3b1df54b15913dcbcaef112

Revert "langref: emphasize the use of dereferencing string literals"

This reverts commit 27353bb936a161e6a09f1424ce38bf84e78e94e4. * unnecessary example * poor phrasing (avoid "you")

1 files changed, 1 insertions(+), 10 deletions(-)

doc/langref.html.in+1-10
...@@ -896,18 +896,9 @@ pub fn main() void {...@@ -896,18 +896,9 @@ pub fn main() void {
896 The type of string literals encodes both the length, and the fact that they are null-terminated,896 The type of string literals encodes both the length, and the fact that they are null-terminated,
897 and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and897 and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and
898 {#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}.898 {#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}.
899 Dereferencing string literals converts them to {#link|Arrays#}.
899 </p>900 </p>
900 <p>901 <p>
901 Dereferencing string literals converts them to {#link|Arrays#}, allowing you to initialize a buffer with the contents of a string literal.
902 </p>
903 {#code_begin|syntax|mutable_string_buffer#}
904test {
905 var buffer = [_]u8{0}**256;
906 const home_dir = "C:/Users/root";
907 buffer[0..home_dir.len].* = home_dir.*;
908}
909 {#code_end#}
910 <p>
911 The encoding of a string in Zig is de-facto assumed to be UTF-8.902 The encoding of a string in Zig is de-facto assumed to be UTF-8.
912 Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal903 Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal
913 in source code carry their UTF-8 meaning into the content of the string in the Zig program;904 in source code carry their UTF-8 meaning into the content of the string in the Zig program;