Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » InitCaps() proposal
InitCaps() proposal [message #31899] Tue, 05 April 2011 09:44 Go to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Hello Mirek

Now InitCaps() function converts the first letter after a space to upper, and converts the rest to lower.

However there are problems if there are punctuation marks.

For example InitCaps("Lennon ,John") = "Lennon ,john"

This could be solved changing

	spc = IsSpace(c);

with

	spc = !IsLetter(c);


Best regards
Iñaki
Re: InitCaps() proposal [message #31900 is a reply to message #31899] Tue, 05 April 2011 09:52 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
wouldn't it convert also string like "3rd" to "3Rd"?
Re: InitCaps() proposal [message #31901 is a reply to message #31900] Tue, 05 April 2011 11:26 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
mr_ped wrote on Tue, 05 April 2011 09:52

wouldn't it convert also string like "3rd" to "3Rd"?

Right. Change !IsLetter(c) with !IsLeNum(c).


Best regards
Iñaki
Re: InitCaps() proposal [message #31902 is a reply to message #31899] Tue, 05 April 2011 15:40 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
BTW the same problem solved from completely different POV:
"Lennon ,John" is wrong string typographically anyway, special characters like dots, commas, etc. should follow the previous letter immediately and they should have trailing space.
So the correct string is "Lennon, John". Razz
Re: InitCaps() proposal [message #31916 is a reply to message #31902] Wed, 06 April 2011 17:06 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
Well, another example

InitCaps("Charlotte Fitz-Stuart") == "Charlotte Fitz-stuart"

This is not right Smile


Best regards
Iñaki
Re: InitCaps() proposal [message #31917 is a reply to message #31901] Wed, 06 April 2011 17:41 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 05 April 2011 05:26

mr_ped wrote on Tue, 05 April 2011 09:52

wouldn't it convert also string like "3rd" to "3Rd"?

Right. Change !IsLetter(c) with !IsLeNum(c).


You mean !IsLetter(c) && !IsDigit(c), right? (Not the same as IsAlNum).
Re: InitCaps() proposal [message #31918 is a reply to message #31917] Wed, 06 April 2011 18:39 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
mirek wrote on Wed, 06 April 2011 17:41

koldo wrote on Tue, 05 April 2011 05:26

mr_ped wrote on Tue, 05 April 2011 09:52

wouldn't it convert also string like "3rd" to "3Rd"?

Right. Change !IsLetter(c) with !IsLeNum(c).


You mean !IsLetter(c) && !IsDigit(c), right? (Not the same as IsAlNum).

Oh yes. I said IsLeNum() Smile


Best regards
Iñaki
Re: InitCaps() proposal [message #31920 is a reply to message #31918] Thu, 07 April 2011 10:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 06 April 2011 12:39

mirek wrote on Wed, 06 April 2011 17:41

koldo wrote on Tue, 05 April 2011 05:26

mr_ped wrote on Tue, 05 April 2011 09:52

wouldn't it convert also string like "3rd" to "3Rd"?

Right. Change !IsLetter(c) with !IsLeNum(c).


You mean !IsLetter(c) && !IsDigit(c), right? (Not the same as IsAlNum).

Oh yes. I said IsLeNum() Smile


Ops, sry, thought it is just typo. Did not even knew we have that Smile

Anyway, patch applied.
Re: InitCaps() proposal [message #31922 is a reply to message #31920] Thu, 07 April 2011 10:56 Go to previous message
koldo is currently offline  koldo
Messages: 3357
Registered: August 2008
Senior Veteran
mirek wrote on Thu, 07 April 2011 10:21

koldo wrote on Wed, 06 April 2011 12:39

mirek wrote on Wed, 06 April 2011 17:41

koldo wrote on Tue, 05 April 2011 05:26

mr_ped wrote on Tue, 05 April 2011 09:52

wouldn't it convert also string like "3rd" to "3Rd"?

Right. Change !IsLetter(c) with !IsLeNum(c).


You mean !IsLetter(c) && !IsDigit(c), right? (Not the same as IsAlNum).

Oh yes. I said IsLeNum() Smile


Ops, sry, thought it is just typo. Did not even knew we have that Smile

Anyway, patch applied.

Smile


Best regards
Iñaki
Previous Topic: Value: why not float support?
Next Topic: why not "T & Add(const T & x)" in all containers
Goto Forum:
  


Current Time: Thu Apr 25 21:11:43 CEST 2024

Total time taken to generate the page: 0.06365 seconds