Case Insensitive in D

github logo Updated on ・1 min read

Python (14 Part Series)

1) Boolean in D 2) Comments in D 3 ... 12 3) Raise Exceptions in D 4) Add to a List in D 5) Count of a List in D 6) String Contained in a String in D 7) Where did my string go in D 8) Case Insensitive in D 9) Add to a Dictionary in D 10) Check Dictionary has key in D 11) Filter a Dictionary in D 12) Split, Apply, Merge in D 13) Map Reduce in D 14) Skip the first line of a file in D

Let me begin with the naive approach before I tell you to go with the naive approach.

import std.string;

assert("I be Big".toLower == "i be big");

As I mentioned last time unicode isn't simple. Well it isn't easier with changing characters and this mostly isn't a unicode problem. The upper/lowercase of a character in one language changes in another. This is where localization comes into play.

I'm actually not very well verse in this area so question my advice. If you're not working in data that crosses language boundaries then this change is mostly moot.

I haven't seen a solution in D for handling this. I only briefly looked into it for this article. So continue using toLower as was recommended to me for Python.

twitter logo DISCUSS
Classic DEV Post from May 7 '19

The newly announced future of .NET - unifying all the things

Microsoft announces .NET 5

Jesse Phillips profile image
Long time solo programmer. Building CI/CD and having the opportunity to improve collaboration.

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️