Is character ‘g’ in UUID valid?

Did you know UUID has a very detailed specification? Well, if you did, good for you, if you didn’t, it’s okay, you can read it now.

For some reason, I always thought UUID (or GUID) is a random collection of numbers and characters and randomness guarantees uniqueness. I was pretty sure about the randomness but wasn’t sure that presence of character ‘g’ makes it invalid.

Let’s look at UUID’s definition. UUID is in fact a random 128 bit number and it’s represented using hexadecimal numbers for the sake of readability. Now, let me ask you the same question again:

Is character ‘g’ in UUID valid?

Ofcourse, it’s not valid!

Why?

Because hexadecimal digits don’t include ‘g’. Therefore, a valid UUID should always match:

/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i

So, presence of ‘g’ in UUID means that UUID specification has not been implemented correctly in the programming language.

About andhapp

Namastey (Hello) Stranger, This is not the geekiest blog on the planet yet it is not the dumbest one either. I am a small time developer who likes to explore new technologies. I usually program in Java, Groovy and Ruby and take keen interest in the surrounding geeky developments.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>