20

Is anyone aware of some code/rules on how to capitalize the names of people correctly?

  • John Smith
  • Johan van Rensburg
  • Derrick von Gogh
  • Ruby de La Fuente
  • Peter Maclaurin
  • Garry McDonald

(these may not be correct, just some sample names and how the capitalization could be/work)

This seems like a losing battle...

If anyone has some code or rules on when and how to capitalize names, let me know :)

Cheers, Albert

Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
Albert
  • 1,062
  • 2
  • 13
  • 20
  • 10
    My bet is on "impossible". – msw Mar 17 '10 at 23:48
  • 4
    Remember, Ian McDonald (from Scotland) has a different capitalization from Ian Mcdonald (from Ireland). – Jonathan Leffler Mar 17 '10 at 23:58
  • @naysayers, everything is possible. – AMissico Mar 18 '10 at 00:08
  • 2
    When in doubt, ALL CAPS. – Juliet Mar 18 '10 at 00:11
  • 4
    @Amissico: Actually, no, it isn't. See http://en.wikipedia.org/wiki/Halting_problem – Billy ONeal Mar 18 '10 at 01:32
  • Actually, it is..."Sometimes, close enough is good enough." http://msdn.microsoft.com/en-us/library/bb263911(VS.85).aspx. From the answers provided, I am sure Albert will find a way. – AMissico Mar 18 '10 at 03:59
  • I'm wondering how it'd be to have a suggestion pop-up when they onblur after entering their last name. If it's all lower case perhaps, they can then choose to correct it. If it's complex, show some options, when they click submit, that is the end of the story... – Albert Mar 18 '10 at 05:00
  • 1
    Awareness in application development, anywhere a surname, or any part of their name is presented outward is pretty important. Our most basic rule is simply, "believe the user, on what the correct spelling is, for their own name." Never change mixed casing unless it's done, as I call it, "legal style," ALL CAPS. Or "uni style," all lowercase. Anything other than those two exceptions, and you've literally spelled their name wrong. We have 2 fields in a table for this. users.search_name : ALL UPPERCASE, "USER MCCLURE"; users.display_name: Presented exactly the same as given, "User McClure" – JBMcClure Feb 23 '23 at 01:30

4 Answers4

19

The only sensible way to handle it, in my opinion, is to let the users tell you how their name should be capitalized. Any automatic scheme is going to annoy someone.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
7

Just tell them you're OLD SCHOOL. That makes it simple and 100% correct:

- JOHN SMITH
- JOHAN VAN RENSBURG
- DERRICK VON GOGH
- RUBY DE LA FUENTE
- PETER MACLAURIN
- GARRY MCDONALD

The same logic also helps with many i18n problems.

Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
  • 1
    Marc Harisson - agree. people tend to get annoyed when you get their names wrong ... – Rook Mar 18 '10 at 01:35
  • 5
    this is not quite viable in an application though. Imagine your outlook contacts were all UPPER CASE, I think I'd go deaf :\ It could be usefull in some instances though, not this one. – Albert Mar 18 '10 at 04:43
  • 3
    @Albert - Oh, I wish people would stop with that allcaps=loud shouting equality. They're letters like all else. Nothing special about them if they're all caps. – Rook Mar 18 '10 at 15:42
  • 4
    I tell them I'm so old school I don't even use computers. Thus the whole programming problem is circumvented. – Slothario Jan 21 '15 at 16:40
2

There's also this implementation in Python which is based on this algorithm. The basic idea is convert the name to title case then check the name against a giant look-up table of exceptions.

But really what Jonathan Leffler said is spot on: unless you have some requirement to convert pre-existing unformatted data, automated capitalization is going to do something wrong (especially as capitalization rules vary across language divides, cultural divides, name changes that result from emigration or people just preferring to capitalize their name in some particular fashion).

moomoohk
  • 483
  • 1
  • 8
  • 23
ig0774
  • 39,669
  • 3
  • 55
  • 57
  • Without going through the list of exceptions associated with that algorithm, I'd bet on it's being quite incomplete with regards to polish names starting with 'Mac'. – mc0e Jun 25 '13 at 07:32
1

I kept a lookup of names that needed special handling. When a case-insensitive match was found, I used the lookup value. This did not resolve people who used case that did not match the "accepted" capitalization. It allowed me/user to add names as needed. I can't find my code, but I did get the surnames from http://www.census.gov/.

AMissico
  • 21,470
  • 7
  • 78
  • 106