Some questions about strings

Adam D. Ruppe destructionator at gmail.com
Mon Jun 22 03:24:37 UTC 2020


On Monday, 22 June 2020 at 03:17:54 UTC, Denis wrote:
> - First, is there any difference between string, wstring and 
> dstring?

Yes, they encode the same content differently in the bytes. If 
you cast it to ubyte[] and print that out you can see the 
difference.

> - Are the characters of a string stored in memory by their 
> Unicode codepoint(s), as opposed to some other encoding?

no, they are encoded in utf-8, 16, or 32 for string, wstring, and 
dstring respectively.

> - Can a series of codepoints, appropriately padded to the 
> required width, and terminated by a null character, be directly 
> assigned to a string WITHOUT GOING THROUGH A DECODING / 
> ENCODING TRANSLATION?

no, they must be encoded. Unicode code points are an abstract 
concept that must be encoded somehow to exist in memory (similar 
to the idea of a number).


More information about the Digitalmars-d-learn mailing list