Well that has already been converted and turned into a UDF.

TranslateName() - converts a name from one type to another

Between this and the other 2 links given you should easily be able to get back any type of information you're looking for.