| ... | ... | @@ -896,18 +896,9 @@ pub fn main() void { |
| 896 | 896 | The type of string literals encodes both the length, and the fact that they are null-terminated, |
| 897 | 897 | and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and |
| 898 | 898 | {#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}. |
| 899 | Dereferencing string literals converts them to {#link|Arrays#}. |
| 899 | 900 | </p> |
| 900 | 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#} |
| 904 | | test { |
| 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 | 902 | The encoding of a string in Zig is de-facto assumed to be UTF-8. |
| 912 | 903 | Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal |
| 913 | 904 | in source code carry their UTF-8 meaning into the content of the string in the Zig program; |