Higher level built-in strings

%u ae at au.com
Mon Jul 19 08:13:03 PDT 2010


> 5) foreach(c; s1) yields a code point dchars regardless if s1 is string,
dstring, wstring.
> But you can use foreach(char c; s1) if s1 is a string and you are sure s1 uses
only 7 bit chars. But in such cases you can also use a immutable(ubyte)[]. Python3
does something similar, its has a str type that's always UTF16 (or UTF32) and a
bytes type that is similar to a ubyte[]. I think D can do something similar.
std.string functions can made to work on ubyte[] and immutable(ubyte)[] too.

Actually I think D should depreciate char and wchar in user code except inside
externals for compatibility with C and Windows functions.

When you are working with individual characters you almost always want either a
dchar or a byte.


More information about the Digitalmars-d mailing list