On Wednesday, 29 January 2020 at 06:53:15 UTC, Jonathan M Davis
wrote:
On Tuesday, January 28, 2020 10:17:03 PM MST Marcone via
Digitalmars-d-learn wrote:
[...]
Of course it is. string is immutable(char)[], and the
characters are in UTF-8. immutable(wchar)[] would would be
UTF-16. Even casting between those two types would result in
nonsense, because UTF-8 and UTF-16 are different encodings.
Casting between array or pointer types basically causes one
type to be interpreted as the other. It doesn't convert the
underlying data in any fashion. Also, strings aren't
null-terminated in D, so having a pointer to a random string
could result in a buffer overflow when you try to iterate
through the string via pointer as is typical in C code. D code
just uses the length property of the string.
[...]
+ Just a reminder that string literals are null-terminated.