10 ms·
Even more awesome is that the capitalised version is TÜRKİYE, not TÜRKIYE, which is what you get if you call something like "Türkiye".ToUpper(); It's going to
by jiggawatts 4y ago
Even more awesome is that the capitalised version is TÜRKİYE, not TÜRKIYE, which is what you get if you call something like "Türkiye".ToUpper();
It's going to be fun to watch developers wrap their heads around that one...
- jakub_g 4y ago(if you're curious: Turkish has dotted and dotless "i": https://simple.wikipedia.org/wiki/Dotted_and_dotless_I https://simple.wikipedia.org/wiki/Dotted_and_dotless_I)
- korlja 4y ago.ToUpper() is locale-dependent, so can only be used if the locale of the text in question is known. E.g. German ß capitalizes to SS, and .ToUpper().ToLower() should give you either 'ss' or 'ß' depending on what it was before. Always outputting 'ss' is okish and readable, but actually wrong. Blindly calling .ToUpper() on anything is a typical anglo-centric mistake. Just don't use .ToUpper(), shoutcase is ugly anyways ;) See also: one of the many "100 fallacies programmers assume about natural written language" documents or such.
- egeozcan 4y ago> German ß capitalizes to SS, and .ToUpper().ToLower() should give you either 'ss' or 'ß' depending on what it was before As long as there is no unicode SS character, we are into the "what color are your bits" problem or tolower needs to be language and word aware. In .NET the uppercase and lowercase functions are culture aware (with defaults to system settings, which breaks more software than you might think) but not word aware AFAIK.
- bee_rider 4y ago> As long as there is no unicode SS character, we are into the "what color are your bits" problem or tolower needs to be language and word aware. It turns out there is such a unicode character -- ẞ/ß -- although based on other comments here it looks like it was added fairly recently. Upper/Lower case stuff just seems to be at an annoying intersection where it has cultural and also programming significance. Or at least, people will use toUpper when they really want some case-insensitive sortable version of the string. (based on some googling, probably localeCompare is the way to go in javascript at least).
- 3836293648 4y agoI hate the locale nonsense. The decimal point is `.` and not `,`. The rest of this stupid country is wrong
- bbu 4y agoOnly sz should use ß. Ss stays ss even in German-german. Switzerland got rid of the sz/ss distinction a long time ago. So you need to be culture and word aware to do it „right“.
- korlja 4y ago'sz' for 'ß' is sometimes used to make things roundtrip-proof in capslock, e.g. on military stencils. HTML calls it 'szlig'. Also, some use "Esszet" as the name of the character. But all are wrong in that ß isn't a ligature of s and z, it is a ligature of s and s. The shape of the character stems from the fact that in fractur writing and even some grotesk fonts, 's' at the end of a word was written 's', while 's' within a word was written 'ſ'. Thus the end of a word like Fuss was written Fuſs, giving a ligature of Fuß. No 'z' anywhere.
- mzs 4y agoI always thought that German z used to look something between Ꙁ & з. ʒ looks pretty close so ſз became ß but Latin transliteration rules were ss instead. At least that's what I was taught in German class.
- kmm 4y agoOriginally ß arose as a ligature of s and z, or rather ſ and ʒ. In many older texts, or even current fonts, the second part of the ligature is indisputably a long-tailed ʒ https://en.wikipedia.org/wiki/%C3%9F https://en.wikipedia.org/wiki/%C3%9F
- seszett 4y ago> some use "Esszet" as the name of the character I believe the actual name is Eszett.
- wanderingstan 4y agoOnly “wrong” in light of current usage, but not historically. By this measure, the English name of “W” would be wrong because it’s not actually a “double-U” but a “double-V”. But at the time of the letter’s formation, U and V were not yet separate letters. https://en.wikipedia.org/wiki/W https://en.wikipedia.org/wiki/W
- Hamuko 4y ago>Blindly calling .ToUpper() on anything is a typical anglo-centric mistake. Yes, one that you might make if you were for example, trying to make English text uppercase. Which is why it would be daft for anyone to suggest that their country has two different English spellings depending on the character case.
- AdrianoKF 4y agoSmall nitpick: uppercase ẞ was added to Unicode 5.1 in 2007 (https://unicode-table.com/en/1E9E/ https://unicode-table.com/en/1E9E/) and is considered correct German orthography since 2017 (see §25 E3 in https://grammis.ids-mannheim.de/rechtschreibung/6180#par25E3 https://grammis.ids-mannheim.de/rechtschreibung/6180#par25E3)
- korlja 4y agoThat is correct and solves the roundtrip-problem (in this case and language). But uppercase 'ẞ' is just an additional option at the discretion of the writer, the recommended variant continues to be 'SS'.
- usr1106 4y agoHow often do you see the new letter in German everyday life? Despite being German myself I don't visit Germany that often these days, I still read a couple of German publications regularly. I have never seen the new letter outside of discussions by software people about character handling.
- gumby 4y agoI assumed it was added for shop signs and product packaging (I.e. as a gimmick). Speaking of surviving Fraktur ligatures, I’m sorry that a couple of others like tz didn’t make it to Roman. It makes poor ß appear lonely.
- AdrianoKF 4y agoI was actually wondering if the driving factor is legal documents. ID cards show names in all-caps letters, which creates the dilemma that your ID might not show your actual name (notwithstanding international standards for travel documents that prescribe transliteration of non-latin characters; see ICAO Doc 9303 Part 3, section 6 [0] for examples) [0]: https://www.icao.int/publications/Documents/9303_p3_cons_en.pdf https://www.icao.int/publications/Documents/9303_p3_cons_en....
- 4y ago
- d1sxeyes 4y ago.toUpper() is a quick and mostly effective way to normalise strings for comparison if you're not sure what case the two strings to compare are in (eg: one has been input by a user). Yes, it's a shortcut, and occasionally you'll end up with a miss, but it's good enough to work 99% of the time, and the alternative is a LOT of code and data changes to handle a very small proportion of cases.
- vesinisa 4y agoHmm I think you miss the point. In some programming environments (like C# and Java) .toUpper() is always incorrect in code unless you are displaying the resulting string in a UI, as it uses the "current locale", which is whatever the user has selected for the machine. When e.g. comparing strings case-insensitively, you should always explicitly specify the locale where the conversion should happen instead of relying on an external configuration variable. JavaScript actually seems to be the smart one here - its default .toUpperCase() uses the "locale-insensitive case mappings in the Unicode Character Database".
- d1sxeyes 4y agoI did indeed. Thanks - yes, I was referring to JavaScript's .toUpperCase(), silly oversight and assumption on my side. Thanks for the correction!
- greenshackle2 4y ago> the user has selected for the machine I don't think most Java and C# software is desktop apps? Surely in most cases it's the locale selected for the server or VM, which should be consistent? (I'm not saying it's good coding practice, mind you, but it probably ends up accidentally working in a lot of cases.)
- vesinisa 4y agoYou write like you can know how and where the code will get executed in the future. :) Do you think that the authors of Windows 95 ever imagined the system would one day get ported to an obscure subset of a functional scripting language (Asm.js variety of JavaScript), and get booted in a hyper-text browser running on a PDA device with internet connection (web browser on a smartphone)? Yet - here we are: https://win95.ajf.me/ https://win95.ajf.me/ > I'm not saying it's good coding practice, mind you, but it probably ends up accidentally working in most cases Fully agree. It's still bad practice and I high-five every linter that automatically flags it.
- underwater 4y agoYou make a good case (ha!). What if toUpper() and toLower() were omitted from standard libraries? Usually they are used, incorrectly, to do something like string comparison, which could be better served by a more specific method.
- egeozcan 4y agoSometımes you see people wrıte lıke thıs or THİS when they are unused to the Turkish keyboard and it creates a lot of problems for some software, even crashes (to upper and back to lower is not the same word!).
- sebazzz 4y agoThat's complicated: "Türkiye".ToUpperInvariant() "Türkiye".ToUpper() TÜRKIYE "Türkiye".ToUpper([System.Globalization.CultureInfo]::GetCultureInfo("tr-TR")) TÜRKİYE
- devoutsalsa 4y agoI just got this... > "Türkiye".capitalize() UniquenessError("Ankara is already the capital")
- eesmith 4y agoSomething's wrong with your implementation. That shouldn't be a uniqueness constraint as a country may have multiple capitals. https://en.wikipedia.org/wiki/List_of_countries_with_multiple_capitals#More_than_one_capital_at_present https://en.wikipedia.org/wiki/List_of_countries_with_multipl... Also, "Nauru".capitalize() should succeed as it has no official capital. (tongue firmly in cheek ;)
- zinekeller 4y agoCan someone help me? Is this an error? "Switzerland".capitalize() "HELVETICA"
- throw0101a 4y agoSwitzerland has four official languages, with the English word "Switzerland" having a particular translation to each one. But if you choose a single official name in one of those languages, it is not fair to the others, so in addition an official name in each language, they have an official in a 'neutral' language: Latin. > Due to its linguistic diversity, Switzerland is known by a variety of native names: Schweiz [ˈʃvaɪts] (German);[note 5] Suisse [sɥis(ə)] (French); Svizzera [ˈzvittsera] (Italian); and Svizra [ˈʒviːtsrɐ, ˈʒviːtsʁɐ] (Romansh).[note 6] On coins and stamps, the Latin name, Confoederatio Helvetica – frequently shortened to "Helvetia" – is used instead of the four national languages. * https://en.wikipedia.org/wiki/Switzerland https://en.wikipedia.org/wiki/Switzerland That's also why the ccTLD of Switzerland is .ch. What you're seeing may be an 'artifact' of that.
- nemoniac 4y agoIn Python: >>> "Türkiye".upper() 'TÜRKIYE' >>> import locale >>> locale.setlocale(locale.LC_ALL, "tr_TR.UTF-8") 'tr_TR.UTF-8' >>> "Türkiye".upper() 'TÜRKIYE' # Expect "TÜRKİYE" >>> locale.resetlocale()
- gumby 4y agoThank you for calling locale.resetlocale() before exiting.
- wyldfire 4y agoMaybe there should be a context manager?
- nerdponx 4y agoAbsolutely. It's not that hard to write your own though: import locale from contextlib import contextmanager @contextmanager def use_locale(*args, **kwargs): locale.setlocale(*args, **kwargs) yield locale.resetlocale() Contextlib is one of the under-appreciated gems in Python: https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager https://docs.python.org/3/library/contextlib.html#contextlib...
- catskul2 4y ago> Maybe there should be a context manager? Even despite the: > Absolutely. My absolute least favorite response to this is: > It's not that hard to write your own though:
- nerdponx 4y agoThe alternative is trying to get one merged into the standard library. At least writing your own is better than not having one!
- twawaaay 4y ago> It's going to be fun to watch developers wrap their heads around that one... No, it will not. Nobody gives a damn. Nobody will implement it. I am still trying to get people to correctly denote beginning and end of a day (much more useful, practical). Everybody I work with seems to be bent on using 23:59:59 as the end of the day rather than start of next day. Explaining that there is no 1s delay between end of one day and start of the next isn't helping either.
- rhn_mk1 4y agoHuh? 23:59:59 is neither, it's one second early.
- wongarsu 4y agoI think that's the point, people insist on using 23:59:59 as end of day instead of the correct 24:00:00 (which happens to be the same instant as 00:00:00 of the next day, since there's no gap between days)
- twawaaay 4y agoMy working theory on why this happens is that there are two different models and people sometimes have problem choosing the correct one. When you say "Thursday" you mean entire 24h period. It is not a point in time, it is a label for a span of time. But when you say "1 pm" you don't mean an entire hour, you mean a point in time that is more or less precisely 1pm. It seems people extend the first model to a lot of cases where it is not correct. And so for many people their mental model of 23:59:59 is a label for a span of time that is one second in length. If your model is that a day consists of 86400 "seconds", each second being a span of time of length of one second with a label like 12:37:28, then 23:59:59 is the last second of the day and 00:00:00 is the first second of the next day.
- rhn_mk1 4y agoWorking with spans is fraught with peril, though. It invites off-by-one errors. If there's one person in the queue to the checkout, then span-wise, that person is the start of the queue and the end of the queue. But if the start and end are the same, what is the length of the queue? (If you still insist it's one, you'll not be able to answer the question where the start and end of an empty queue is. There is no first or last person!)
- behnamoh 4y agoIt's crazy to assume people will use umlauts in URLs. As far as internet users are concerned, TÜRKİYE is turkiye, end of story. PS. It's much easier to type umlauts on Mac. Just hold 'u' to see the variants.
- deleted 4y ago[deleted]
- jws 4y agoAs a Mac user from the beginning I was about to say "that's an iPad, not a Mac", but lo and behold! On a Mac now the alphabetic and digit keys do not autorepeat when held but instead pop up little menus of variants. Shifted alphabetic keys get different variants appropriate to their letter. Sadly for TÜRKİYE the single dot capital "i" is not one of them. At least for my settings, none of the digits get options, nor do they autorepeat. A completely useful overloading of "long press" of a keyboard key, but completely undiscoverable unless you make long strings of "vvvvvvvvv" as a pointer or some such, then you get a disappointment instead of what you wanted, but you will be enlightened.
- spc476 4y agoNot everywhere. In Terminal, the letters just repeat.
- seydor 4y ago> watch developers wrap their heads <img src="/img/turkiye.gif" alt="Turkey" />
- GaelFG 4y agoI find it funny, Turkey was aldready a good test case for handling international users data :), I spend some hours on a bug in json with integer parsing of some users integer inputs in rares cases. It was because of the way they write/parse integer using dots as separators. (Yes, the real problem was me having forgot to force server and client to use the same locale settings :) ) An old article talking of it : https://blog.codinghorror.com/whats-wrong-with-turkey/ https://blog.codinghorror.com/whats-wrong-with-turkey/
- nerdponx 4y agoBut `"türki̇ye".upper()` works correctly, at least in Python 3.9. Interestingly, `"türki̇ye".title()` does _not_ work correctly, returning `"Türki̇Ye"`, presumably because the "title-case" algorithm incorrectly detects \xcc\x87 as punctuation. Not sure if this has been fixed in 3.10 or 3.11. Python 3.9.13 (main, May 24 2022, 21:13:51) [Clang 13.1.6 (clang-1316.0.21.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> s = 'TÜRKİYE' >>> s.lower() 'türki̇ye' >>> s.lower().upper() 'TÜRKİYE' >>> s.lower().title() 'Türki̇Ye' >>> s.lower().encode() b't\xc3\xbcrki\xcc\x87ye Edit: It turns out that this behavior is documented [0], and the more-correct routine is `string.capwords` [1]: > The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word boundaries, which may not be the desired result ... The string.capwords() function does not have this problem, as it splits words on spaces only. [0]: https://docs.python.org/3/library/stdtypes.html#str.title https://docs.python.org/3/library/stdtypes.html#str.title [1]: https://docs.python.org/3/library/string.html#string.capwords https://docs.python.org/3/library/string.html#string.capword...
- Bedon292 4y agoCompared this vs another comment and its interesting. Pulled the strings directly from the ISO website. I wonder if the 'i' in the lower case one is supposed to be special and not ASCII? Python 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> short_name_lower = "Türkiye" >>> short_name = "TÜRKİYE" >>> short_name.encode() ## The Ü and İ are UTF-8 chars b'T\xc3\x9cRK\xc4\xb0YE' >>> short_name_lower.encode() ## Note only the ü is special, i is just ASCII b'T\xc3\xbcrkiye' >>> short_name.lower() 'türki̇ye' >>> short_name_lower.lower() 'türkiye' >>> short_name.lower() == short_name_lower.lower() ## Looks the same, but it isn't False >>> short_name.lower().encode() ## The i has extra \xcc\x87 here b't\xc3\xbcrki\xcc\x87ye' >>> short_name_lower.lower().encode() ## The i doesn't have the extra here b't\xc3\xbcrkiye' >>> short_name_lower.upper().encode() ## So this is wrong too, since its just an ASCII i to start b'T\xc3\x9cRKIYE' Edit: Formatting
- Asooka 4y agoThat's horrible. The Turkish "i" is a never ending source of locale nightmares. I really wish they would pick a new letter for one of the sounds and use the standard "i" for the other. Like maybe use a diaresis.
- diegoperini 4y agoI wish the word "read" is read as read instead of read in past tense form.
- IlliOnato 4y agoFunny, there was a time when I was still learning English (well, it's a never-ending process, but still), and for quite some time I was using "red" as a past tense of "read"! No spell-checker ever corrected me :-) In fact no one did, I just noticed one day that it's not how it's spelled in books...
- int_19h 4y agoIPA uses ɨ for the central sound.
- deleted 4y ago[deleted]
- dolmen 4y agoDevelopers should just use Unicode CLDR data. https://cldr.unicode.org/ https://cldr.unicode.org/ https://unicode-org.github.io/cldr-staging/charts/latest/summary/tr.html#26e11b12fbd13aed https://unicode-org.github.io/cldr-staging/charts/latest/sum...
- sedatk 4y agoThis doesn't have any provisions for upper-case representation.
- deleted 4y ago[deleted]