French and Greek strings

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Nov 17 01:05:47 UTC 2021


On Wed, Nov 17, 2021 at 12:58:43AM +0000, pascal111 via Digitalmars-d-learn wrote:
> How can I use types to make string and char variables that hold French
> and Greek characters?

For strings, just use `string`. :-)  D strings are Unicode by default,
no further effort is needed to use it.

Individual characters are a bit more tricky.  Usually you can just use
dchar, but keep in mind that a dchar is not always the same thing as an
on-screen character.  The latter can sometimes be composed of multiple
dchars; if for whatever reason you need to handle this distinction, you
need to use std.uni.Grapheme.  (It's a bad idea to use Grapheme by
default, because grapheme segmentation is very expensive and will slow
down your program if overused. Don't use it unless you actually need
to.)


T

-- 
If the comments and the code disagree, it's likely that *both* are wrong. -- Christopher


More information about the Digitalmars-d-learn mailing list