Chris
Chris

Reputation: 82

Given Name Formatting

To anyone who can help, Thanks

Okay, so I have a database holding a customer list. The problem that I am having is that I have found that all the entries for the customers First and Last names are stored in all Uppercase letters. And I wanted to know if anyone knows of some utility that I could use to convert the names to their correct casing. I thought about just making everything lowercase and the making the first letter uppercase, but this will not always be correct in all instances. I would also like to be able to do this in Java if at all possible.

Upvotes: 2

Views: 792

Answers (5)

Chris Klepeis
Chris Klepeis

Reputation: 9983

Heres a SQL function you can use to capitalize the first name and last name (assuming they are in seperate fields)

Also heres some regex to capitalize the name if its all in 1 field

Upvotes: 0

devuxer
devuxer

Reputation: 42354

Does this help?

http://www.johncardinal.com/tmgutil/capitalizenames.htm

It sounds like it's VB not Java, but I thought I'd throw it out there.

-Dan

Upvotes: 0

McAden
McAden

Reputation: 13972

Lowercasing all but the first letter will work in most cases.

Otherwise you can have exceptions based upon whether the last name has a space in it, or if it starts with a certain substring (Mc_, Van _...can't think of any others...).

The question really is if it's worth it.

Upvotes: 0

John Kugelman
John Kugelman

Reputation: 361585

A quick Google search turned up http://freejava.info/capitalize-english-names/:

There are names in the English language like Sam O'Neil, Jenny McCarthy, Beverly d'Angelo, Leonardo di Caprio, Don Alejandro de la Vega, Wernher von Braun, etc. that give us trouble when we try to properly capitalize them in software applications. The following java code helps in situation where capitalization of names is required.

The code there capitalizes the letter after "d'", "Mc", or "Mac", or after any punctuation, and has an exception list for "Macintosh", "von", "van", "de", "la", "da", and "di".

Upvotes: 5

Kathy Van Stone
Kathy Van Stone

Reputation: 26271

Since names nowadays can be artbirarily capitalized there is no general algorithm for capitilization that you can use. Some are culture dependent -- I capitalize Van in my name because my family has been in America for a long time, but it would be van in Dutch (but only when following my given name according to this article). The easiest algorithm to use would probably to capitalize the first letter of each word in the name and keep a table of exceptions. If the table gets large you can look at it and derive other rules. The article above lists some standard American rules if you want to start with that (such as don't captialize "de").

Upvotes: 1

Related Questions