On Monday, 15 January 2018 at 02:05:32 UTC, Chris P wrote:
Hello,
I'm extremely new to D and have a quick question regarding
common practice when using strings. Is usage of one type over
the others encouraged? When using 'string' it appears there is
a length mismatch between the string length and the char array
if large Unicode characters are used. So I figured I'd ask.
Thanks in advance,
Chris P - Tampa
string == immutable( char)[], char == utf8
wstring == immutable(wchar)[], char == utf16
dstring == immutable(dchar)[], char == utf32
Unless you are dealing with windows, in which case you way need
to consider using wstring, there is very little reason to use
anything but string.
N.B. when you iterate over a string there are a number of
different "flavours" (for want of a better term) you can iterate
over, bytes, unicode codepoints and graphemes ( I'm possible
forgetting some). have a look in std.uni and related modules.
Iteration in Phobos defaults to coepoints I think.
TLDR use string.