toggleCase() for Narrow String
Paul Backus
snarwin at gmail.com
Sun Apr 13 17:40:38 UTC 2025
On Sunday, 13 April 2025 at 17:28:12 UTC, Salih Dincer wrote:
> Hi,
>
> Please watch: https://youtu.be/siw602gzPaU
>
> If he had learned this method like me, he would not have needed
> if's and long explanations. :)
>
> It's a very redundant thing (ASCII magic) that also weeds out
> the incompatible character set. This approach adopts the
> toggle/flip method through XOR rather than toLower/toUpper:
This is clever, but you are still missing something important.
Take a look at this example:
string test = "I love dlang!";
test.toggleCase().writeln(); // "iLOVEDLANG" - wrong!
More information about the Digitalmars-d-learn
mailing list