{"id":106430,"date":"2022-04-04T07:00:00","date_gmt":"2022-04-04T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=106430"},"modified":"2022-04-02T05:31:47","modified_gmt":"2022-04-02T12:31:47","slug":"20220404-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20220404-00\/?p=106430","title":{"rendered":"How are Windows Runtime GUIDs represented in JavaScript?"},"content":{"rendered":"<p>One of the fundamental data types in the Windows Runtime is the <code>Guid<\/code>. In most languages, it is represented as a binary-formatted data type like <code>System.Guid<\/code> or <code>winrt::guid<\/code>. But JavaScript doesn&#8217;t have a corresponding data type. So how are Windows Runtime <code>Guid<\/code>s represented in JavaScript?<\/p>\n<p>As strings.<\/p>\n<p>But strings in a special format.<\/p>\n<p>If a Windows Runtime function accepts a <code>Guid<\/code>, the JavaScript projection accepts a string in one of the following formats:<\/p>\n<table class=\"cp3\" style=\"border-collapse: collapse;\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<th>Format<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><code>aaaaaaaabbbbccccddeeffgghhiijjkk<\/code><\/td>\n<td>Raw hex<\/td>\n<\/tr>\n<tr>\n<td><code>aaaaaaaa-bbbb-cccc-ddee-ffgghhiijjkk<\/code><\/td>\n<td>Hex with dashes<\/td>\n<\/tr>\n<tr>\n<td><code>(aaaaaaaa-bbbb-cccc-ddee-ffgghhiijjkk)<\/code><\/td>\n<td>Hex with dashes enclosed in parentheses<\/td>\n<\/tr>\n<tr>\n<td><code>{aaaaaaaa-bbbb-cccc-ddee-ffgghhiijjkk}<\/code><\/td>\n<td>Hex with dashes enclosed in braces<\/td>\n<\/tr>\n<tr>\n<td><code>{ 0xaaaaaaaa, 0xbbbb, 0xcccc,<br \/>\n{ 0xdd, 0xee, 0xff, 0xgg, 0xhh, 0xii, 0xjj, 0xkk } }<\/code><\/td>\n<td>C initializer<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Letters <code>a<\/code> through <code>k<\/code> represent any hexadecimal digit. All parsing is case-insensitive. (That includes the <code>x<\/code> in the <code>0x<\/code> of the C initializer format.)<\/p>\n<p>In all cases, leading and trailing whitespace are ignored. A whitespace character is one which is classified as whitespace in Unicode version 6.2, which was the latest version of Unicode at the time JavaScript support was implemented.<\/p>\n<table class=\"cp3\" style=\"border-collapse: collapse;\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<th>Character<\/th>\n<th>Code point<\/th>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">CHARACTER TABULATION<\/td>\n<td>U+0009<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">LINE FEED<\/td>\n<td>U+000A<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">LINE TABULATION<\/td>\n<td>U+000B<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">FORM FEED<\/td>\n<td>U+000C<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">CARRIAGE RETURN<\/td>\n<td>U+000D<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">SPACE<\/td>\n<td>U+0020<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">NEXT LINE<\/td>\n<td>U+0085<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">NO-BREAK SPACE<\/td>\n<td>U+00A0<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">OGHAM SPACE MARK<\/td>\n<td>U+1680<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">MONGOLIAN VOWEL SEPARATOR<\/td>\n<td>U+180E<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">EN QUAD<\/td>\n<td>U+2000<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">EM QUAD<\/td>\n<td>U+2001<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">EN SPACE<\/td>\n<td>U+2002<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">EM SPACE<\/td>\n<td>U+2003<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">THREE-PER-EM SPACE<\/td>\n<td>U+2004<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">FOUR-PER-EM SPACE<\/td>\n<td>U+2005<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">IX-PER-EM SPACE<\/td>\n<td>U+2006<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">FIGURE SPACE<\/td>\n<td>U+2007<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">PUNCTUATION SPACE<\/td>\n<td>U+2008<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">THIN SPACE<\/td>\n<td>U+2009<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">HAIR SPACE<\/td>\n<td>U+200A<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">LINE SEPARATOR<\/td>\n<td>U+2028<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">PARAGRAPH SEPARATOR<\/td>\n<td>U+2029<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">NARROW NO-BREAK SPACE<\/td>\n<td>U+202F<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">MEDIUM MATHEMATICAL SPACE<\/td>\n<td>U+205F<\/td>\n<\/tr>\n<tr>\n<td style=\"font-variant-caps: all-small-caps;\">IDEOGRAPHIC SPACE<\/td>\n<td>U+3000<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The <span style=\"font-variant-caps: all-small-caps;\">MONGOLIAN VOWEL SEPARATOR<\/span> is the odd one out: It was originally classified as whitespace but lost that status in Unicode 6.3.<\/p>\n<p>Whitespace is permitted in the C initializer format <i>anywhere<\/i>, not just after commas. Strange but true.<\/p>\n<p>Going the other way is much simpler: If a Windows Runtime function returns a <code>Guid<\/code>, the JavaScript version returns lowercase hex with dashes (no braces or parentheses).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>They&#8217;re strings, in various formats.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-106430","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>They&#8217;re strings, in various formats.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/106430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=106430"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/106430\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=106430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=106430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=106430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}