Proper Case function for names?

  • Does anyone have a really good proper case function for peoples names? - I took a stab at one a little while ago, which is not bad, but still not perfect.

    The most tricky thing seems to be a surname like:

    'Pablo de Monta'

    All the proper case functions, mine included, make this string:

    Pablo de monta.

    I've catered for names like 'van Blogs' so it doesn't make it Van blogs but I can't seem to get the 'compound' names to work.

    The van side of things works using this:

    IF SUBSTRING(@TempString,1,3) = 'van '

    BEGIN

    SET @ps = @ps + 'van '

    SET @TempString = SUBSTRING(@Tempstring,5,LEN(@TempString))

    END

    However, this is always at the start of the string, so it's a known position.

    Things like Pablo van Tricky - the 'van' could be in any position, depending on what was in place of Pablo.

    I fear I may be trying to account for too much - most proper case functions I have found do not tackle these problems, perhaps wth good reason...

  • [font="Verdana"]It's a hard, hard issue. What makes it complicated are names forms like:

    Xxx Vvv Yyy

    Xxx vvv Yyy

    Xxx VvYyy

    Xxx vvYyy

    Xxx V'Yyy

    Xxx v'Yyy

    I can remember finding valid names matching all of those forms. Oh, not to mention that many european names can contain all sorts of interesting characters.

    [/font]

  • Yeah, it's a complete minefield - I might build an exceptions table - so if the name contains '% van %' then skip propercase, various other special characters etc

    One blog on the subject basically (wisely) states that some people are pretty sensitive to how their name is written - perhaps in some circumstances just stick with what they put! - That's all great until someone registeres as Mr. A. A. !

  • I have said it a lot - proper-casing names is a losing proposition and I would not recommend it.

    The funny thing is, I just saw a name that will mess up nearly all of your rules for proper-casing or parsing a name.

    The new German minister of economic affairs, named..get this "Karl Theodor Maria Nikolaus Johann Jacob Philipp Franz Joseph Sylvester Freiherr von und zu Guttenberg"

    Good luck.

  • lol, our firstname field's probably a varchar(50) or something, that would blow him out :p

  • peitech (2/13/2009)


    lol, our firstname field's probably a varchar(50) or something, that would blow him out :p

    As far as I can tell, his first name is Karl - so I think you are good there.

    It's his middle and last names that I can't really follow.

  • The real issue is that names can follow multiple rules.

    McDonald and Mcdonald are both correct - for different people.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply