String range to dchar.

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 30 18:46:14 PDT 2014


On Fri, Oct 31, 2014 at 12:17:00AM +0000, Samuel Pike via Digitalmars-d-learn wrote:
> Hi all.
> 
> First time posting here. I recently downloaded the dmd compiler and
> started making a few exercises with the language. Nice language
> features but still somewhat confused with the library.
> 
> If I use byDchar() over a "string" is there a possibility to get part
> of a character or is guaranteed that the entire visual character will
> be in the dchar?
[...]

A dchar corresponds with a Unicode code point, but that doesn't always
correspond with a "visual character" (e.g., if you have a base character
followed by a combining diacritic, they would come out as two dchars).
The Unicode term for "visual character" is "grapheme". If you want to
process the string by grapheme, use byGrapheme() from std.uni.


T

-- 
EMACS = Extremely Massive And Cumbersome System


More information about the Digitalmars-d-learn mailing list