Questions tagged [title-case]

In string or sentence formatting, title case is the term used for capitalizing the first character of each principal word.

In string or sentence formatting, title case is the term used for capitalizing the first character of each principal word.

95 questions
25
votes
16 answers

How do I convert a string to title case in android?

I searched high and low but could only find indirect references to this type of question. When developing an android application, if you have a string which has been entered by the user, how can you convert it to title case (ie. make the first…
Russ
  • 3,768
  • 7
  • 28
  • 37
13
votes
3 answers

Any difference between str.capitalize() and str.title()?

Is there any difference in str.title() vs str.capitalize()? My understanding from the docs is that both methods capitalize the first letter of a word and make the rest of the letters lowercase. Did anyone run into a situation where they cannot be…
mysl
  • 1,003
  • 2
  • 9
  • 19
13
votes
4 answers

Converting php string to Title Case

I want to convert an input string to Title Case. So, if I have an input string Name: MR. M.A.D KARIM I want to produce the following output string Name: M.A.D Karim And if I have an input string Address: 12/A, ROOM NO-B 13 I want to…
Atik Khan
  • 483
  • 1
  • 5
  • 10
13
votes
9 answers

Convert First character of each word to upper case

I have a String and I need to convert the first letter of each word to upper case and rest to lower case using xsl, For example, Input String= dInEsh sAchdeV kApil Muk Desired Output String= Dinesh Sachdev Kapil Muk Although, I know I have to use…
dinesh028
  • 2,137
  • 5
  • 30
  • 47
9
votes
4 answers

Make string title case using ucfirst

I'm probably missing something really obvious. While converting a bunch of string before inserting them in a array I noticed some string where different among each other because of first char being uppercase or not. I decided then to use ucfirst to…
Fabio
  • 23,183
  • 12
  • 55
  • 64
7
votes
5 answers

Python: Is there a one line script to title case strings except for strings that start with a digit?

The title() method works great, but I have a situation where there are strings that start with both words and numbers and I only want to titlecase the words in the string that do not begin with numbers. The number of numbers can be variable, and…
Startec
  • 12,496
  • 23
  • 93
  • 160
6
votes
3 answers

Make all words lowercase and the first letter of each word uppercase

I have a string with improper capitalization scattered like below: $str = "tHis iS a StRinG thAt NeEds ProPer CapiTilization"; $newStr = ucfirst($str); echo $newStr; How would I be able to capitalize the first letter of each word and lower case the…
HelloWorld
  • 335
  • 2
  • 7
5
votes
1 answer

Why replace `capitalize` with a check for whether it is lowercase before `titlecase` is called?

When using Kotlin 1.5, Android Studio warns that String.capitalize is deprecated. The suggested replacement is: myString.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }) Why is the check for…
Moshe Katz
  • 15,992
  • 7
  • 69
  • 116
5
votes
1 answer

How do i capitalize a variable in mustache

I have this variable in my mustache template called type, i want to capitalise the value of type using title case, is this possible ? taking into consideration that type is not what is displayed on the web page, it stores a value. {{type}}
floormind
  • 1,868
  • 5
  • 31
  • 85
5
votes
4 answers

Javascript convert unicode string to "Title Case"

I have a javascript case conversion problem which I cannot solve due to non-English letters. My main concern is the Turkish alphabet. What I need to do is this: hello world => Hello World HELLO WORLD => Hello World hELLO wOrLd => Hello World Here…
Serkan Durusoy
  • 5,447
  • 2
  • 20
  • 39
4
votes
2 answers

reveal.js title with capitalized words but not in uppercase

I am preparing slides using markdown and using pandoc to convert them to HTML slides for use with reveal.js. The resulting titles default to uppercase. I want them to appear in "titlecase" where each word is capitalized, but not all letters…
chandra
  • 292
  • 2
  • 11
4
votes
1 answer

Proper title case in ICU [Does ICU have a list of non-capitalized words?]

Is it possible to obtain proper capitalization for e.g. English text using ICU4C but without building any custom set of non-capitalized words? Say, given pining for the fjords I'd like to obtain Pining for the Fjords. With ucasemap_utf8ToTitle() and…
gagolews
  • 12,836
  • 2
  • 50
  • 75
3
votes
2 answers

Why TextInfo.ToTitleCase does not work correctly on a string whose letters are all in upper case?

Could you have a look at my sample? This result produces from the following example: var str = @"VIENNA IS A VERY BEAUTIFUL CAPITAL CITY."; var title = new CultureInfo("en-US",…
Habip Oğuz
  • 921
  • 5
  • 17
3
votes
4 answers

Apply title-case to all words in string except for nominated acronyms

Example Input: SMK SUNGAI PUNAI My Code: $school = 'SMK SUNGAI PUNAI'; echo ucwords(strtolower($school)); Unwanted Output: Smk Sungai Punai Question How to make the output SMK Sungai Punai which allows SMK to remain in ALL-CAPS. Update. The…
iamafish
  • 817
  • 3
  • 13
  • 24
3
votes
3 answers

Make first letter of each word/name uppercase, unless a known all-lowercase component of a surname

I use PHP to insert form entries into a MySQL database. Sometimes users enter text in all caps. Is there any way to change it so that only the first letters are capitalized? ucwords(strtolower($word)) won't work for me because I do not want to…
Brian
  • 26,662
  • 52
  • 135
  • 170