Decoding of Strings as Ranges of dchar
Explore how D treats strings as ranges of Unicode code points through automatic decoding into dchar elements. Understand the difference between accessing raw UTF code units and decoded characters, and learn when to use string representations for direct code unit manipulation. This lesson helps you handle strings flexibly and correctly in advanced D programming.
We'll cover the following...
Automatic decoding of strings
Being character arrays by definition, strings can also be used as ranges just by importing std.array. However, char and wchar strings cannot be used as RandomAccessRange.
std.array provides a special functionality with all types of strings. Iterating over strings becomes iterating over Unicode code points, not over UTF code units. As a result, strings appear as ranges of Unicode characters.
The following ...