Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does guid have special formats? [duplicate]

Possible Duplicate:
Why is the GUID structure declared the way it is?

i've been looking a GUID generation and handling and is wondering why Microsoft has decided these "strange" formats.

A single format specifier that indicates how to format the value of this Guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used.

Say what?

Format flags goes as following:

N: 32 digits = 00000000000000000000000000000000

D: 32 digits separated by hyphens = 00000000-0000-0000-0000-000000000000

B: 32 digits separated by hyphens, enclosed in braces = {00000000-0000-0000-0000-000000000000}

P: 32 digits separated by hyphens, enclosed in parentheses = (00000000-0000-0000-0000-000000000000)

X: Four hexadecimal values enclosed in braces, where the fourth value is a subset of eight hexadecimal values that is also enclosed in braces = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}

Why???

Why not a 00000000-00000000-00000000-00000000

or 0000-0000-0000-0000-0000-0000-0000-0000 ??

Does any one have a good answer, except its Microsoft? :o)

like image 236
BerggreenDK Avatar asked Jul 06 '11 14:07

BerggreenDK


People also ask

Can GUID be duplicate?

It's possible to generate an identical guid over and over. However, the chances of it happening are so low that you can assume they are unique.

Are all GUIDs the same format?

Types of GUIDsThere a 5 versions of GUIDs defined in RFC 4122, each with different properties. To identify the version of the GUID, just look at the version digit e.g version 4 GUIDs have the format xxxxxxxx-xxxx-4xxx-Nxxx-xxxxxxxxxxxx where N is one of 8,9,A, or B.

Why do GUIDs have hyphens?

Long sequences are very hard to parse for humans, hence the hyphens.

Can GUID have special characters?

Yes, a byte in a Guid could have any value between #0~#255.


1 Answers

UUID/GUID have standard representations according to RFC-4122. Simpler explanation here.

like image 137
Ioan Avatar answered Sep 29 '22 09:09

Ioan