4 ms·
> Has anyone here ever had a use case for toLower() where they actually wanted localization to apply? On many documents, including Turkish passport and identit
by smnrchrds 6y ago
> Has anyone here ever had a use case for toLower() where they actually wanted localization to apply?
On many documents, including Turkish passport and identity card and many (all?) other passports, names are written in all caps. Maybe toLower() is not that useful, but toUpper() is crucial in any application where you are dealing with real person names.
- phonebanshee 6y agotoUpper is definitely language-dependent. For example, in Irish there are initial letters that are written as lower-case even in all caps. Wikipedia's example is amusing, since it's a photo of a government passport office sign - the all-caps version of Oifig na bPasanna is OIFIG NA bPASANNA (photo https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/ALLCAPS_OIFIG_NA_bPASANNA.JPG/440px-ALLCAPS_OIFIG_NA_bPASANNA.JPG https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/AL..., article https://en.wikipedia.org/wiki/Irish_orthography#Capitalisation https://en.wikipedia.org/wiki/Irish_orthography#Capitalisati...). It would look utterly bizarre to write OIFIG NA BPASANNA. And this isn't at all an unusual construction in Irish, it happens in personal names all the time. Plus, there's the issue of diacritical marks. Irish keeps long marks over capitals, but French drops accents. Do you plan to do é => É (required for Irish - POBLACHT NA hÉIREANN is the all-caps version of Poblacht na hÉireann [the Republic of Ireland]) or é => E (common practice for French)? You have to get it right, and you have to know the language to do that. (Poblacht na hÉireann also illustrates the fact that initial caps is also a language-dependent idea; you absolutely can't write Poblacht Na Héireann - that makes my eyes burn just looking at it.) (And before you say, well, Irish isn't a language spoken by very many people, remember that it's an official language of the European Union. If you're writing software to be used by EU agencies, you're going to have to care.)
- smnrchrds 6y ago> French drops accents Official position of both Académie française and Office québécois de la langue française is that accents must be preserved in capital letters. However, it is common in France to drop them, while they are almost always preserved in Québéc. I have heard that the reason is that European French keyboard layout makes it difficult to type accented capital letters, unlike Québécois French layout which makes writing them easy. But I am not sure if this is the cause rather than the effect of the practice.
- forty 6y agoI confirm that in French capital letters should have accents. I have an anecdote on this: on birth certificates, family names are written in capital letters. It turns out my partner name ends with a É which was written as E in her birth certificate. She never noticed (it had never prevented her to get national ID with her name properly accented) until we had our first kid which has both our names, and they refused to have the name accented until we had my partner's birth certificate updated (which as you can imagine is quite an adventure, since you need to dig ancient family birth certificates to prove it was originally written with an accent...).
- hocuspocus 6y agoWrongly dropping accents on uppercase letters predates computer keyboards; the French azerty layout puts accented letters on the first level of number row: http://j.poitou.free.fr/pro/img/tkn/tw-image.jpg http://j.poitou.free.fr/pro/img/tkn/tw-image.jpg This idiocy carried over. The recent layout update makes dead accents more accessible: https://norme-azerty.fr/ https://norme-azerty.fr/ But I haven't seen much adoption yet.
- zorked 6y agoThat button to the right of the P that contains four different forms of dashes is... interesting. Even more if you consider that the minus sign there is not the character - that is used by every programming language.
- masklinn 6y ago> That button to the right of the P that contains four different forms of dashes is... interesting. And there are two more on the 8 key. I like the mac international keyboard layout, but it still only provides for 4 of those: the non-breaking hyphen and the "proper" minus sign are lacking. I like that the "new azerty" provides for pretty much every diacritic, even those which are not in use in french.
- phonebanshee 6y agoInteresting that I was wrong - another data point in the "it's more complicated than you think it is" column. I always thought you were supposed to drop them (because I was explicitly told so by a French engineer I worked with in the 90s, talking about one particular poster, and many years later still assume that one hallway conversation was enough to make that THE OFFICIAL RULE without bothering to actually check...)
- rurban 6y agoNope, none of them are really useful. The only useful folding function is casefold(str, locale). (if your str type doesn't know it's locale). toLower and toUpper should only be used for presentation, but all case-insensitive operations need to be done with casefold.