9
1
Given a German string and an indication of a case (lower/upper/title), fold the string to that case.
Specifications
- Input will consist only of
a–zplusäöüß-,.;:!?'"in uppercase and/or lowercase. - The target case may be taken as any three unique values (please specify what they are) of a consistent type; either three characters, or three numbers, or three bit patterns. (Other formats are currently not allowed to prevent "outsourcing" the answer to the case specification. Comment if you think that an additional format should be allowed.)
- Titlecase means uppercase everything except letters that follow a letter (letters are
a–zplusäöüß).
Gotchas
When
ßneeds to be uppercase, it must becomeẞ. Some case-folding built-ins and libraries do not do this.When
ßneeds to be titlecase, it must becomeSs. Some case-folding built-ins and libraries do not do this.ssmay occur in the text, and should never be converted toßorẞ.
Examples
Upper case die Räder sagen "ßß ss" für dich, wegen des Öls!
is DIE RÄDER SAGEN "ẞẞ SS" FÜR DICH, WEGEN DES ÖLS!
Lower case die Räder sagen "ßß ss" für dich, wegen des Öls!
is die räder sagen "ßß ss" für dich, wegen des öls!
Title case die Räder sagen "ßß ss" für dich, wegen des Öls!
is Die Räder Sagen "Ssß Ss" Für Dich, Wegen Des Öls!
2What would be the outputs for
Ss? Also, the example input is missing ass– Rod – 8 years ago@Rod
SSSsss. Can you tell me why that's unclear? – Adám – 8 years agoRelated – Poke – 8 years ago
Am I allowed to make the three unique values Python functions? (see my answer) – HyperNeutrino – 8 years ago
No, that's exactly what intended to prevent by specifying that the three unique values must be either characters, numbers or bit patterns. – Adám – 8 years ago
May we assume there are no capitals after the first letter in a word? – darrylyeo – 8 years ago
May we take input and give output in an ANSI codepage containing these symbols instead of UTF-8 etc.? – Οurous – 8 years ago
@Οurous Does such a codepage exist? If so, then I guess that's valid by default. At least as long as you program can fit in the codepage and that your interpreter/compiler will run/compile such files. – Adám – 8 years ago
@HyperNeutrino I think that's a standard loophole actually, taking functions as inputs. I don't remember where the meta is tho – Conor O'Brien – 8 years ago
@ConorO'Brien Oh huh. That would make sense I guess. – HyperNeutrino – 8 years ago
@HyperNeutrino Relevant meta post ConorO'Brien was most likely talking about. EDIT: You were actually the first one to comment on that meta post I now noticed.. ;)
– Kevin Cruijssen – 8 years ago@KevinCruijssen Thanks. And huh that's interesting. I do remember reading and commenting on that meta post but I guess that the time I was trying to use that as a solution I didn't consider that :P – HyperNeutrino – 8 years ago
But... gotcha #1 isn’t making sense, uppercase ß is just SS, a friend of mine has a 4 letter lowercase name and a 5 letter uppercase...? – Stan Strum – 8 years ago
@StanStrum Encoding has nothing to do with names. ß is a two-letter ligature. – Adám – 8 years ago
@Adám not quite what I meant, but i see where you’re going. Just never really see an upper ß – Stan Strum – 8 years ago
@StanStrum It has been in use for over half a century.
– Adám – 8 years ago