On Thursday, 6 September 2018 at 08:44:15 UTC, nkm1 wrote:
On Wednesday, 5 September 2018 at 07:48:34 UTC, Chris wrote:
On Tuesday, 4 September 2018 at 21:36:16 UTC, Walter Bright
wrote:
Autodecode - I've suffered under that, too. The solution was
fairly simple. Append .byCodeUnit to strings that would
otherwise autodecode. Annoying, but hardly a showstopper.
import std.array : array;
import std.stdio : writefln;
import std.uni : byCodePoint, byGrapheme;
import std.utf : byCodeUnit;
void main() {
string first = "á";
writefln("%d", first.length); // prints 2
auto firstCU = "á".byCodeUnit; // type is `ByCodeUnitImpl`
(!)
writefln("%d", firstCU.length); // prints 2
auto firstGr = "á".byGrapheme.array; // type is `Grapheme[]`
writefln("%d", firstGr.length); // prints 1
auto firstCP = "á".byCodePoint.array; // type is `dchar[]`
writefln("%d", firstCP.length); // prints 1
dstring second = "á";
writefln("%d", second.length); // prints 1 (That was easy!)
// DMD64 D Compiler v2.081.2
}
And this has what to do with autodecoding?
Nothing. I was just pointing out how awkward some basic things
can be. autodecoding just adds to it in the sense that it's a
useless overhead but will keep string handling in a limbo forever
and ever and ever.
TBH, it looks like you're just confused about how Unicode
works. None of that is something particular to D. You should
probably address your concerns to the Unicode Consortium. Not
that they care.
I'm actually not confused since I've been dealing with Unicode
(and encodings in general) for quite a while now. Although I'm
not a Unicode expert, I know what the operations above do and
why. I'd only expect a modern PL to deal with Unicode correctly
and have some guidelines as to the nitty-gritty.
And once again, it's the user's fault as in having some basic
assumptions about how things should work. The user is just too
stoooopid to use D properly - that's all. I know this type of
behavior from the management of pubs and shops that had to close
down, because nobody would go there anymore.
Do you know the book "Crónica de una muerte anunciada" (Chronicle
of a Death Foretold) by Gabriel García Márquez?
"The central question at the core of the novella is how the death
of Santiago Nasar was foreseen, yet no one tried to stop it."[1]
[1]
https://en.wikipedia.org/wiki/Chronicle_of_a_Death_Foretold#Key_themes