News for hackers. Stuff that matters.
Re:A popular but wrong way to convert a string to uppercase ... by vardump on Tuesday October 08, 2024 @04:53AM (#41775153)
As always, Raymond is right. (And as usually, I could guess it's him before even clicking the link.)

That said, 99% time when doing upper- or lowercase operation you're interested just in the 7-bit ASCII range of characters.

For the remaining 1%, there's ICU library. Just like Raymond Chen mentioned.

Re:A popular but wrong way to convert a string to uppercase ... by sebstefan on Tuesday October 08, 2024 @06:01AM (#41775511)
Yes please, keep making software that mangles my actual last name at every step of the way. 99% of the world loves it when you only care about the USA.
Re:A popular but wrong way to convert a string to uppercase ... by Muromec on Tuesday October 08, 2024 @06:13AM (#41775607)
If it needs to uppercase names it probably interfaces with something forsaken like Sabre/Amadeus that only understands ASCII anyway.

The real problem is accepting non-ASCII input from user where you later assume it's ASCII-only and safe to bitfuck around.

Re:A popular but wrong way to convert a string to uppercase ... by InfamousRece on Tuesday October 08, 2024 @08:13AM (#41776465)
Some systems are still using EBCDIC.
Re:A popular but wrong way to convert a string to uppercase ... by sebstefan on Tuesday October 08, 2024 @07:06AM (#41776002)
From experience anything banking adjacent will usually fuck it up as well

For some reason they have a hard-on for putting last names in capital letters and any other treatment just won't fly.

Re:A popular but wrong way to convert a string to uppercase ... by Muromec on Tuesday October 08, 2024 @09:52AM (#41777384)
If it uses ASCII anyway, what's the problem then? Don't accept non-ASCII user input.
Re:A popular but wrong way to convert a string to uppercase ... by sebstefan on Tuesday October 08, 2024 @10:01AM (#41777484)
First off: And exclude 70% of the world?

Usually they'll accept it, but some parts of the backend are still running code from the 60's.

So you get your name rendered properly on the web interface, and most core features, but one day you're wandering off from the beaten path, by, like, requesting some insurance contract, and you'll see your name at the top with some characters mangled, depending on what your name's like. Mine is just accented latin characters so it usually drops the accents ; not sure how it would work if your name was in an entirely different alphabet

Re:A popular but wrong way to convert a string to uppercase ... by Muromec on Tuesday October 08, 2024 @04:16PM (#41781414)
>First off: And exclude 70% of the world?

Guess what, I'm part of this 70% and I also work in a bank and I know exactly how.

Not a single letter in my name (any of them) can be represented with ASCII. When it is represented in UTF-8, most of the people who have to see it can't read it anyway.

So my identity document issued by the country which doesn't use Latin alphabet includes ASCII-representation of my name in addition to canonical form in Ukrainian Cyrillic. That ASCII-rendering is happily accepted by all kinds of systems that only speak ASCII.

People still can't pronounce it and it got misspelled like yesterday when dictated over the phone.

Now regarding the accents, it's illegal to not support them per GDPR (as per case law, discussed here few years ago).

Re:A popular but wrong way to convert a string to uppercase ... by numpad0 on Tuesday October 08, 2024 @08:19PM (#41783224)
Why can't these people understand that that 70% of the world consider ASCII to be "the computer language", not English, and UTF-8 to be "whatever soup that only works inside files and forms and can't be program manipulated"?

Maybe it needs to be communicated more often, like way more often, until it sticks.

Re:A popular but wrong way to convert a string to uppercase ... by Muromec on Wednesday October 09, 2024 @01:36PM (#41790523)
Well, it's much easier to understand the difference when one and another are using different alphabets.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:46AM (#41788462)
You are not being excluded just because you need to use a romanized version of your name. Clear example of a first world problem.
Re:A popular but wrong way to convert a string to uppercase ... by sebstefan on Thursday October 10, 2024 @07:04AM (#41797616)
>first world problem

? The more first world you are the more your alphabet is taken into consideration

Hint: You use the word """romanized"""

Re:A popular but wrong way to convert a string to uppercase ... by MajimasEyepatch on Tuesday October 08, 2024 @07:31PM (#41782911)
It’s totally reasonable to assume your users are in the US if your business only sells to people in the US. I work in the health insurance sector; there’s absolutely no chance my company ever sells these products internationally. We can’t even sell them in every state.
Re:A popular but wrong way to convert a string to uppercase ... by davidcbc on Tuesday October 08, 2024 @07:47PM (#41783011)
It's not reasonable to assume that users in the US have names that only use 7-bit ASCII
Re:A popular but wrong way to convert a string to uppercase ... by bigstrat2003 on Tuesday October 08, 2024 @11:13PM (#41784154)
It actually is. That covers the vast, vast majority of people in the US.
Re:A popular but wrong way to convert a string to uppercase ... by saagarjha on Monday October 14, 2024 @04:50AM (#41835557)
That is not very reasonable, is it?
Re:A popular but wrong way to convert a string to uppercase ... by MajimasEyepatch on Tuesday October 15, 2024 @12:04PM (#41849991)
It is if all your customers are in the US.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:51AM (#41788518)
It's reasonable to assume that all users can deal with having to encode their names in 7-bit ASCII. Otherwise you might as well demand that computer systems need to support arbitrary drawings in the name field at which point you might as well not have a name field at all because even most humans won't be able to deal with what you want to put in there.
Re:A popular but wrong way to convert a string to uppercase ... by davidcbc on Wednesday October 09, 2024 @06:58PM (#41793705)
Nice slippery slope you've got there
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:44AM (#41788450)
Cool, I will.
Re:A popular but wrong way to convert a string to uppercase ... by fhars on Tuesday October 08, 2024 @05:03AM (#41775216)
No, when you are doing string manipulation, you are almost never interestet in just the seven bit ASCII range, as there is almost no language that can be written using just that.
Re:A popular but wrong way to convert a string to uppercase ... by vardump on Tuesday October 08, 2024 @05:12AM (#41775255)
> as there is almost no language that can be written using just that.

99% of use cases I've seen have nothing to do with human language.

1% human language case that is needs to be handled properly using a proper Unicode library.

Your mileage (percentages) may vary depending on your job.

Re:A popular but wrong way to convert a string to uppercase ... by kergonath on Tuesday October 08, 2024 @06:06AM (#41775546)
Right. That’s why I still get mail with my name mangled and my street name barely recognisable. Because I’m in the 1%. Too bad for me…

In all seriousness, though, in the real world ASCII works only for a subset of a handful of languages. The vast majority of the population does not read or write any English in their day to day lives. As far as end users are concerned, you should probably swap your percentages.

ASCII is mostly fine within your programs like the parser you mention in your other comment. But even then, it’s better if a Chinese user name does not break your reporting or logging systems or your parser, so it’s still a good idea to take Unicode seriously. Otherwise, anything that comes from a user or gets out of the program needs to behave.

Re:A popular but wrong way to convert a string to uppercase ... by vardump on Tuesday October 08, 2024 @06:12AM (#41775600)
I said use a Unicode library if input data is actual human language. Which names and addresses are.

99% case being ASCII data generated by other software of unknown provenance. (Or sometimes by humans, but it's still data for machines, not for humans.)

Re:A popular but wrong way to convert a string to uppercase ... by kergonath on Tuesday October 08, 2024 @09:04AM (#41776927)
I am really not sure about this 99%. A lot of programs deal with quite a lot of user-provided data, which you don’t control.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:56AM (#41788581)
User-provided data, yes, but also data where you can treat non-ASCII bytes as garbage in -> garbage out. E.g. the config file might be typed by a human but if you need to support case-insensitive keys you still don't need to worry about Unicode.
Re:A popular but wrong way to convert a string to uppercase ... by kergonath on Thursday October 10, 2024 @06:08PM (#41804076)
Exactly. But in this case, don’t try to upper-case or otherwise transform anything.
Re:A popular but wrong way to convert a string to uppercase ... by Muromec on Tuesday October 08, 2024 @06:14AM (#41775623)
Who and why still tries to lowercase/uppercase names? Please tell them to stop.
Re:A popular but wrong way to convert a string to uppercase ... by kergonath on Tuesday October 08, 2024 @09:05AM (#41776932)
Hell if I know. I don’t know what kind of abomination e-commerce websites run on their backend, I just see the consequences.
Re:A popular but wrong way to convert a string to uppercase ... by numpad0 on Tuesday October 08, 2024 @08:34PM (#41783312)
> That’s why I still get mail with my name mangled

Which is why you always type out addresses in ASCII representations in any foreign transactions even if it's not going to match your identity documents, unless the other party specifically demands it in UTF-8 and insists that they can handle it.

> it’s better if a Chinese user name does not break your reporting or logging systems

You should not be just casually dumping Chinese usernames into logs without warnings, in fact, you should not be using Chinese characters for usernames at all. Lots of Chinese online services exclusively use numeric IDs and e-mails for login IDs. "Usernames in natural human language" is a valid concept only in ASCII cultural sphere.

Re:A popular but wrong way to convert a string to uppercase ... by kergonath on Thursday October 10, 2024 @06:07PM (#41804072)
> Which is why you always type out addresses in ASCII representations in any foreign transactions even if it's not going to match your identity documents, unless the other party specifically demands it in UTF-8 and insists that they can handle it.

That is not always possible and the translation from local writing system to ASCII is often not unique and ambiguous. There really is no excuse for this sort of thinking. Even American programmers have to realise at some point that programs serve some purpose and that their failure to represent how the world works is just that: a failure. There is no excuse for programs to not support UTF-8 from user input to any output, including all the processing in between.

Re:A popular but wrong way to convert a string to uppercase ... by Factory on Tuesday October 08, 2024 @09:00PM (#41783435)
"The vast majority of the population does not read or write any English in their day to day lives." This is doubtful: https://en.wikipedia.org/wiki/List_of_languages_by_total_num... While English speakers are not a majority, it is the most popular language. And one should also note that given English is the lingua franca of programming, I'd suspect that English as a second language is actually a majority for programmers. So any code that deals solely with programmers as users can easily just use standard ASCII as default, and never see any problems.
Re:A popular but wrong way to convert a string to uppercase ... by kergonath on Thursday October 10, 2024 @06:03PM (#41804050)
> "The vast majority of the population does not read or write any English in their day to day lives." This is doubtful: https://en.wikipedia.org/wiki/List_of_languages_by_total_num... While English speakers are not a majority, it is the most popular language.

That is the number of English-speaking people, as in people who can speak English. Not necessarily people who use it every day. In any case, ASCII only works for a subset of even English if you ignore all loan words and diacritics in things like proper names.

> So any code that deals solely with programmers as users can easily just use standard ASCII as default, and never see any problems.

That would not be much code at all, given that most code deals with user interfaces or user-provided data. That is the point: it’s not because the code is in basic English simplified enough to fit in ASCII that you can ignore Unicode and don’t need to consider text encoding.

Re:A popular but wrong way to convert a string to uppercase ... by 9dev on Tuesday October 08, 2024 @05:21AM (#41775310)
It's funny how software developers live in bubbles so much. Whether you deal with human language a lot or almost not at all depends entirely on your specific domain. Anyone working on user interfaces of any kind must accommodate for proper encoding, for example; that includes pretty much every line-of-business app out there, which is a lot of code.
Re:A popular but wrong way to convert a string to uppercase ... by elpocko on Tuesday October 08, 2024 @06:32AM (#41775771)
Every search feature everywhere has to be case-insensitive or it's unusable. Search seems like a pretty ubiquitous feature in a lot of software, and has to work regardless of locale/encoding.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:58AM (#41788601)
Search needs a whole lot more normalization than just case folding.
Re:A popular but wrong way to convert a string to uppercase ... by elpocko on Wednesday October 09, 2024 @06:24PM (#41793390)
Okay.
Re:A popular but wrong way to convert a string to uppercase ... by inexcf on Tuesday October 08, 2024 @05:41AM (#41775402)
Why do you need upper- or lowercase conversion in cases that have nothing to do with human language?
Re:A popular but wrong way to convert a string to uppercase ... by vardump on Tuesday October 08, 2024 @05:51AM (#41775451)
Here's an example. Hypothetically say you want to build an HTML parser.

You might encounter tags like <html>, <HTML>, <Html>, etc., but you want to perform a hash table lookup.

So first you're going to normalize to either lower- or uppercase.

Re:A popular but wrong way to convert a string to uppercase ... by Muromec on Tuesday October 08, 2024 @06:16AM (#41775642)
But but, I want to have a custom web component and register it under my own name, which can only be properly written in Ukrainian Cyrillic. How dare you not let me have it.
Re:A popular but wrong way to convert a string to uppercase ... by inexcf on Tuesday October 08, 2024 @08:30AM (#41776614)
Ah, i see, we disagree on what is "human language". An abbreviation like HTML and it's different capitalisations to me sound a lot like a feature of human language.
Re:A popular but wrong way to convert a string to uppercase ... by recursive on Tuesday October 08, 2024 @02:24PM (#41780264)
Is this a serious argument? Humans don't directly use HTML to communicate with each other. It's a document markup language rendered by user agents, developed against a specification.
Re:A popular but wrong way to convert a string to uppercase ... by tannhaeuser on Tuesday October 08, 2024 @05:04PM (#41781806)
Markup languages and SGML in particular absolutely are designed for digital text communication by humans and to be written using plain text editors; it's kindof the entire point of avoiding binary data constructs.

And to GP, SGML/HTML actually has a facility to define uppercasing rules beyond ASCII, namely the LCNMSTRT, UCNMSTRT, LCNMCHAR, UCNMCHAR options in the SYNTAX NAMING section in the SGML declaration introduced in the "Extended Naming Rules" revision of ISO 8879 (SGML std, cf. https://sgmljs.net/docs/sgmlrefman.html). Like basically everything else on this level, these rules are still used by HTML 5 to this date, and in particular, that while elements names can contain arbitrary characters, only those in the IRV (ASCII) get case-folded for canonization.

Re:A popular but wrong way to convert a string to uppercase ... by recursive on Tuesday October 08, 2024 @07:58PM (#41783073)
HTML is a text-based medium. But that doesn't make it a human language. Some human languages are not text-based. And some text is not a human language.

ANSI C was designed to be written by humans using a plain text editor. That doesn't make it a human language.

Re:A popular but wrong way to convert a string to uppercase ... by ARandumGuy on Tuesday October 08, 2024 @02:45PM (#41780449)
Converting string case is almost never something you want to do for text that's displayed to the end user, but there are many situations where you need to do it internally. Generally when the spec is case insensitive, but you still need to verify or organize things using string comparison.
Re:A popular but wrong way to convert a string to uppercase ... by daemin on Tuesday October 08, 2024 @05:12AM (#41775253)
I would argue that for most programs when you're doing string manipulation you're doing it for internal programming reasons - logs, error messages, etc. In that case you are in nearly full control of the strings and therefore can declare that you're only working with ASCII.

The other normal cases of string usage are file paths and user interface, and the needed operations can be done with simple string functions, and even in UTF8 encoding the characters you care about are in the ASCII range. With file paths the manipulations that you're most often doing is path based so you only care about '/', '\', ':', and '.' ASCII characters. With user interface elements you're likely to be using them as just static data and only substituting values into placeholders when necessary.

Re:A popular but wrong way to convert a string to uppercase ... by pistoleer on Tuesday October 08, 2024 @05:23AM (#41775318)
> I would argue that for most programs when you're doing string manipulation you're doing it for internal programming reasons - logs, error messages, etc. In that case you are in nearly full control of the strings and therefore can declare that you're only working with ASCII.

Why would you argue that? In my experience it's about formatting things that are addressed to the user, where the hardest and most annoying localization problems matter a lot. That includes sorting the last name "van den Berg" just after "Bakker", stylizing it as "Berg, van den", and making sure this capitalization is correct and not "Van Den Berg". There is no built in standard library function in any language that does any of that. It's so much larger than ascii and even larger than unicode.

Another user said that the main takeaway is that you can't process strings until you know their language (locale), and that is exactly correct.

Re:A popular but wrong way to convert a string to uppercase ... by daemin on Tuesday October 08, 2024 @06:12AM (#41775604)
I would maintain that your program has more string manipulation for error messages and logging than for generating localised formatted names.

Further I do say that if you're creating text for presenting to the user then the most common operation would be replacement of some field in pre-defined text.

In your case I would design it so that the correctly capitalised first name, surname, and variations of those for sorting would be generated at the data entry point (manually or automatically) and then just used when needed in user facing text generation. Therefore the only string operation needed would be replacement of placeholders like the fmt and standard library provide. This uses more memory and storage but these are cheaper now.

Re:A popular but wrong way to convert a string to uppercase ... by pistoleer on Tuesday October 08, 2024 @07:14AM (#41776054)
I agree, but the logging formatters don't really do much beyond trivially pasting in placeholders.

And as for data entry... Maybe in an ideal world. In the current world, marred by importing previously mangled datasets, a common solution in the few companies I've worked at is to just not do anything, which leaves ugly edges, yet is "good enough".

Re:A popular but wrong way to convert a string to uppercase ... by heisenzombie on Tuesday October 08, 2024 @05:26AM (#41775329)
File paths? I think filesystem paths are generally “bags of bytes” that the OS might interpret as UTF-16 (Windows) or UTF-8 (macOS, Linux).

For example: https://en.m.wikipedia.org/wiki/Program_Files#Localization

Re:A popular but wrong way to convert a string to uppercase ... by vardump on Tuesday October 08, 2024 @05:28AM (#41775338)
File paths are scary. The last I checked (which is admittedly a while ago), Windows didn't for example care about correct UTF-16 surrogate pairs at all, it'd happily accept invalid UTF-16 strings.

So use standard string processing libraries on path names at your own peril.

It's a good idea to consider file paths as a bag of bytes.

Re:A popular but wrong way to convert a string to uppercase ... by netsharc on Tuesday October 08, 2024 @06:00AM (#41775508)
IIRC, the FAT filesystem (before Windows 95) allowed lowercase letters, but there's a layer in the filesystem driver that converted everything to uppercase, e.g. if you did the command "more readme.txt", the more command would ask the filesystem for "readme.txt" and it would search for "README.TXT" in the file allocation table.

I think I once hex-edited the FA-table to change a filename to have a lowercase name (or maybe it was disk corruption), trying to delete that file didn't work because it would be trying to delete "FOO", and couldn't find it because the file was named "FOo".

Re:A popular but wrong way to convert a string to uppercase ... by Someone on Tuesday October 08, 2024 @05:51AM (#41775452)
> It's a good idea to consider file paths as a bag of bytes

(Nitpick: sequence of bytes)

Also very limiting. If you do that, you can’t, for example, show a file name to the user as a string or easily use a shell to process data in your file system (do you type “/bin” or “\x2F\x62\x69\x6E”?)

Unix, from the start, claimed file names where byte sequences, yet assumed many of those to encode ascii.

That’s part of why Plan 9 made the choice “names may contain any printable character (that is, any character outside hexadecimal 00-1F and 80-9F)” (https://9fans.github.io/plan9port/man/man9/intro.html)

Re:A popular but wrong way to convert a string to uppercase ... by daemin on Tuesday October 08, 2024 @05:53AM (#41775466)
That's what I mean, you treat filesystem paths as bags of bytes separated by known ASCII characters, as the only path manipulation that you generally need to do is to append a path, remove a path, change extension, things that only care about those ASCII characters. You only modify the path strings at those known characters and leave everything in between as is (with some exceptions using OS API specific functions as needed).
Re:A popular but wrong way to convert a string to uppercase ... by numpad0 on Tuesday October 08, 2024 @08:47PM (#41783375)
Just using UTF-8 for username at all is problematic. That has been a major PSA item for Windows users in my language literally since 90s and still is. Microsoft switched home folder names from Microsoft Account username to shortened user email for that reason.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @11:04AM (#41788671)
Yes and most importantly, that interpretation is for display purposes ONLY. If your file manager won't let me delete a file because the name includes invalid UTF-16/UTF-8 then it is simply broken.
Re:A popular but wrong way to convert a string to uppercase ... by BoringTimesGang on Tuesday October 08, 2024 @05:24AM (#41775323)
Now double all of that effort, so you can get it to work with Windows' UTF-16 wstrings.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @11:10AM (#41788729)
Better to just convert WTF-16 (Windows filenames re not guaranteed to be valid UTF-16) to/from WTF-8 at the API boundary and then do the same processing internally on all platforms.
Re:A popular but wrong way to convert a string to uppercase ... by crazygringo on Tuesday October 08, 2024 @04:58PM (#41781750)
> That said, 99% time when doing upper- or lowercase operation you're interested just in the 7-bit ASCII range of characters.

I think it's more the exact opposite.

The only times I'm dealing with 7-bit ASCII is for internal identifiers like variable names or API endpoints. Which is a lot of the time, but I can't ever think of when I've needed my code to change their case. It might literally be never.

On the other hand, needing to switch between upper, lower, and title case happens all the time, always with people's names and article titles and product names and whatnot. Which are never in ASCII because this isn't 1990.

Re:A popular but wrong way to convert a string to uppercase ... by hinkley on Tuesday October 08, 2024 @06:53PM (#41782618)
And you could argue that if the internal identifiers need to be capitalized or lower-cased, you've already lost.

On an enterprise app these little string manipulations are a drop in the bucket. In a game they might not be. Sort that stuff out at compile time, or commit time.

Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:44AM (#41788445)
You can't always control the case you get but often you can not care about anything outside ASCII. Scripts and configuration or text-based data formats are common examples.
Re:A popular but wrong way to convert a string to uppercase ... by bigstrat2003 on Tuesday October 08, 2024 @11:12PM (#41784147)
> Which are never in ASCII because this isn't 1990.

This is a very silly statement. I'm willing to believe that you have lots of cases where those things are outside the ASCII range. Perhaps even most of the cases, depending on where you live. But I do not believe for one second that it never happens.

Re:A popular but wrong way to convert a string to uppercase ... by crazygringo on Tuesday October 08, 2024 @11:15PM (#41784166)
Never stored in ASCII, never limited to ASCII. They're UTF-8, usually.

If somebody's name happens to fit into ASCII that's irrelevant because it's not guaranteed, so you can never blindly do an ASCII case conversion.

For text data meant for users, I literally cannot remember the last time I used a string in ASCII format as opposed to UTF-8 (or UTF-16 in JS). It's certainly over a decade ago.

So yes, when I say never, I literally mean never. Nothing "very silly" about it, sorry.

(Again, excepting identifiers, where case conversion is not generally applicable.)

Re:A popular but wrong way to convert a string to uppercase ... by PaulDavisThe1st on Wednesday October 09, 2024 @01:13AM (#41784697)
He may be right, but approximately 75% of the problems he describes are all Microsoft-ecosystem specific.

In Unix-land we don't use wchar_t or UTF-16, and his article is a good demonstrations of why not.

Re:A popular but wrong way to convert a string to uppercase ... by pjmlp on Wednesday October 09, 2024 @03:51AM (#41785502)
UNIX land is even worse in international languages support.

As in, there isn't even something on POSIX at the level other operaring systems support for localisation.

Yes there is some locale stuff, however not enough for all stuff, hence why every modern programming language happens to have this as part of their standard library.

Re:A popular but wrong way to convert a string to uppercase ... by PaulDavisThe1st on Wednesday October 09, 2024 @10:09AM (#41788161)
When the notion of what a "string" is differs so much from language to language, i18n is never going to be an effective part of POSIX.
Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @11:12AM (#41788748)
Is there a platform where you can't use ICU?
Re:A popular but wrong way to convert a string to uppercase ... by yas_hmaheshwari on Wednesday October 09, 2024 @01:50AM (#41784886)
Wow, I came here to write exactly that, and its heartening to see that I am not crazy

Just reading the title, with microsoft.com in bracket, I knew two things: 1. It would be written by Raymond Chen 2. That article is going to be awesome

Re:A popular but wrong way to convert a string to uppercase ... by account42 on Wednesday October 09, 2024 @10:40AM (#41788405)
> That said, 99% time when doing upper- or lowercase operation you're interested just in the 7-bit ASCII range of characters.

And std::tolower/toupper is the wrong tool for that as well.