On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote:
How can I properly convert a character, say, first one to upper
case in a unicode correct manner?
In which code level I should be working on? Grapheme? Or maybe
code point is sufficient?
There are few phobos functions like asCapitalized() none of
which are what I want.
Use `asCapitalized` to capitalize the first letter or use
something like this:
import std.conv;
import std.range;
import std.stdio;
import std.uni;
void main(string[] args)
{
string input = "noe\u0308l";
int index = 2;
auto graphemes = input.byGrapheme.array;
string upperCased = [graphemes[index]].byCodePoint.text.toUpper;
graphemes[index] = upperCased.decodeGrapheme;
string output = graphemes.byCodePoint.text;
writeln(output);
}