{"id":44924,"date":"2015-05-06T07:00:00","date_gmt":"2015-05-06T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2015\/05\/06\/why-is-there-an-invisible-u202a-at-the-start-of-my-file-name\/"},"modified":"2019-03-13T12:15:16","modified_gmt":"2019-03-13T19:15:16","slug":"20150506-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20150506-00\/?p=44924","title":{"rendered":"Why is there an invisible U+202A at the start of my file name?"},"content":{"rendered":"<p>There&#8217;s something strange about this property sheet page: <\/p>\n<table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" TITLE='Explorer file property sheet open to the Security tab.' STYLE=\"color: black;background-color: #f0f0f0;border: solid 1px #5284bc;width: 40em;font-size: 9pt;font-family: Segoe UI, Tahoma, MS Sans Serif, Arial, sans-serif\">\n<tr BGCOLOR=\"#6badf6\" STYLE=\"font-size: 14pt\">\n<td><span STYLE=\"float: left;width: 5px\"><\/span><\/td>\n<td STYLE=\"padding-bottom: 5px\">\n<table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n<tr>\n<td ALIGN=\"center\"><span STYLE=\"float: left;width: 32pt\"><\/span><\/td>\n<td ALIGN=\"center\" VALIGN=\"bottom\" WIDTH=\"100%\">        IMG31415 Properties       <\/td>\n<td ALIGN=\"center\">        <span STYLE=\"float: right;background-color: #c75050;color: white;font-size: 16pt;width: 32pt\">             <b>&times;<\/b>         <\/span>       <\/td>\n<\/tr>\n<\/table>\n<\/td>\n<td><span STYLE=\"float: left;width: 5px\"><\/span><\/td>\n<\/tr>\n<tr>\n<td BGCOLOR=\"#6badf6\"><span STYLE=\"float: left;width: 5px\"><\/span><\/td>\n<td STYLE=\"border: solid 1px #5b93d1;border-bottom-width: 0px;padding: 5px\">\n<table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" STYLE=\"width: 100%\">\n<tr>\n<td VALIGN=\"bottom\">\n<div STYLE=\"border: solid 1px #afafaf;border-right: none;padding: 2px 5px\">           General         <\/div>\n<\/td>\n<td>\n<div STYLE=\"border: solid 1px #afafaf;border-bottom-color: transparent;padding: 2px 5px 3px 5px;height: 1.5em;background-color: white\">           Security        <\/div>\n<\/td>\n<td VALIGN=\"bottom\">\n<div STYLE=\"border: solid 1px #afafaf;border-left: none;padding: 2px 5px\">           Details        <\/div>\n<\/td>\n<td STYLE=\"border-bottom: solid 1px #afafaf;width: 100%\">       &nbsp;       <\/td>\n<\/tr>\n<tr>\n<td COLSPAN=\"4\" STYLE=\"border: solid 1px #afafaf;border-top-color: transparent;background-color: white;padding: 15px\">\n<div STYLE=\"padding-bottom: 1ex\">        Object name: &nbsp; &nbsp; &nbsp; C:\\Users\\Bob\\Desktop\\IMG31415.jpg         <\/div>\n<div STYLE=\"padding-bottom: 1ex\">          Group or user names:         <\/div>\n<table STYLE=\"width: 100%;border: solid 1px #afafaf;text-align: left\">\n<tr>\n<td>              <span>&#x1f464;<\/span>               <span STYLE=\"color: gray\">&nbsp;&#x1f464;<\/span>             <\/td>\n<td STYLE=\"width: 100%;color: white\" BGCOLOR=\"#3399ff\">              SYSTEM             <\/td>\n<\/tr>\n<tr>\n<td>              &nbsp;&#x1f464;             <\/td>\n<td>              Bob             <\/td>\n<\/tr>\n<tr>\n<td>              <span>&#x1f464;<\/span>               <span STYLE=\"color: gray\">&nbsp;&#x1f464;<\/span>             <\/td>\n<td>              Administrators             <\/td>\n<\/tr>\n<tr>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>&nbsp;<\/td>\n<\/tr>\n<\/table>\n<div STYLE=\"padding: 10px 0px\">          To change permissions, click Edit.           <span STYLE=\"float: right;background-color: #f0f0f0;width: 7em;text-align: center;padding: 5px;border: solid 1px #afafaf\">Edit&#8230;<\/span>         <\/div>\n<table CELLSPACING=\"0\" STYLE=\"width: 100%\">\n<thead>\n<tr>\n<td ALIGN=\"left\">Permissions for SYSTEM<\/td>\n<td ALIGN=\"center\">Allow<\/td>\n<td ALIGN=\"center\">Deny<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;border-top: solid 1px #afafaf;padding-left: 10px\">               Full control<\/td>\n<td ALIGN=\"center\" STYLE=\"border-top: solid 1px #afafaf\">              &#x2713;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf;border-top: solid 1px #afafaf\">               &nbsp;<\/td>\n<\/tr>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;padding-left: 10px\">               Modify<\/td>\n<td ALIGN=\"center\">              &#x2713;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf\">              &nbsp;<\/td>\n<\/tr>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;padding-left: 10px\">               Read &amp; execute<\/td>\n<td ALIGN=\"center\">              &#x2713;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf\">              &nbsp;<\/td>\n<\/tr>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;padding-left: 10px\">               Read<\/td>\n<td ALIGN=\"center\">              &#x2713;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf\">              &nbsp;<\/td>\n<\/tr>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;padding-left: 10px\">               Write<\/td>\n<td ALIGN=\"center\">              &#x2713;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf\">              &nbsp;<\/td>\n<\/tr>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;padding-left: 10px\">               Special permissions<\/td>\n<td ALIGN=\"center\">              &nbsp;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf\">              &nbsp;<\/td>\n<\/tr>\n<tr>\n<td ALIGN=\"left\" STYLE=\"border-left: solid 1px #afafaf;border-bottom: solid 1px #afafaf\">               &nbsp;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-bottom: solid 1px #afafaf\">              &nbsp;<\/td>\n<td ALIGN=\"center\" STYLE=\"border-right: solid 1px #afafaf;border-bottom: solid 1px #afafaf\">               &nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div STYLE=\"padding: 10px 0px\">          <span STYLE=\"float: right;background-color: #f0f0f0;width: 7em;text-align: center;padding: 5px;border: solid 1px #afafaf\">Advanced&#8230;<\/span>           For special permissions or advanced settings,           click Advanced.         <\/div>\n<\/td>\n<\/tr>\n<\/table>\n<\/td>\n<td BGCOLOR=\"#6badf6\"><span STYLE=\"float: left;width: 5px\"><\/span><\/td>\n<\/tr>\n<tr>\n<td BGCOLOR=\"#6badf6\"><span STYLE=\"float: left;width: 5px\"><\/span><\/td>\n<td STYLE=\"border: solid 1px #5b93d1;border-top-width: 0px;padding: 5px\">    <span STYLE=\"float: right;width: 7em;text-align: center;padding: 5px;margin: 5px;border: solid 1px #afafaf\">Apply<\/span>     <span STYLE=\"float: right;width: 7em;text-align: center;padding: 5px;margin: 5px;border: solid 1px #afafaf\">Cancel<\/span>     <span STYLE=\"float: right;width: 7em;text-align: center;padding: 5px;margin: 5px;border: solid 1px #afafaf\">OK<\/span>  <\/td>\n<td BGCOLOR=\"#6badf6\"><span STYLE=\"float: left;width: 5px\"><\/span><\/td>\n<\/tr>\n<tr>\n<td COLSPAN=\"3\" BGCOLOR=\"#6badf6\">   <span STYLE=\"float: left;height: 5px;width: 5px\"><\/span><\/td>\n<\/tr>\n<\/table>\n<p>Okay, that was a trick question, because the thing that&#8217;s strange is not visible to the eye. <\/p>\n<p>Use the mouse to click in the object name field (the thing with the file path), then press <kbd>Home<\/kbd>, followed by <kbd>Shift<\/kbd>+<kbd>End<\/kbd> to select the entire text, then <kbd>Ctrl<\/kbd>+<kbd>C<\/kbd> to copy it to the clipboard. <\/p>\n<p>Now things get interesting. <\/p>\n<p>Fire up Notepad, paste the path into the Notepad document, and save it to the desktop with the name <tt>tricky.txt<\/tt>. <\/p>\n<p>Huh? Notepad says, &#8220;This file contains characters in Unicode format which will be lost if you save this as an ANSI encoded text file.&#8221; <\/p>\n<p>What Unicode characters are we talking about? There are no accented letters here. All the characters in the file name fit in the ASCII repertoire. <\/p>\n<p>Go to a command prompt and type <\/p>\n<pre>\nC:\\Users\\Bob&gt; copy \"\n<\/pre>\n<p>and then paste the path from the clipboard, then close the quotation mark, and hit Enter. <\/p>\n<pre>\nC:\\Users\\Bob&gt; copy \"?C:\\Users\\Bob\\Desktop\\IMG31415.jpg\"\nThe filename, directory name, or volume label syntax is incorrect.\n<\/pre>\n<p>Wait, what? Where did that rogue question mark come from? <\/p>\n<p>The answers to the two questions are the same: The mysterious Unicode character, which is invisible in Notepad, and which appears as a question mark on the command line, is U+202A (LEFT-TO-RIGHT EMBEDDING). <\/p>\n<p>We saw <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2013\/12\/19\/10483396.aspx\">some time ago<\/a> that you can, as a last resort, insert the character U+202B (RIGHT-TO-LEFT EMBEDDING) to force text to be interpreted as right-to-left. The converse character is U+202A (LEFT-TO-RIGHT EMBEDDING), which forces text to be interpreted as left-to-right. <\/p>\n<p>The Security dialog box inserts that control character in the file name field in order to ensure that <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2012\/10\/26\/10362864.aspx\">the path components are interpreted in the expected manner<\/a>. Unfortunately, it also means that if you try to copy the text out of the dialog box, the Unicode formatting control character comes along for a ride. Since the character is normally invisible, it can create all sorts of silent confusion. <\/p>\n<p>(We&#8217;re lucky that the confusion was quickly detected by Notepad and the command prompt. But imagine if you had pasted the path into the source code to a C program!) <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The desperation Left-to-right marker.<\/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":[104],"class_list":["post-44924","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>The desperation Left-to-right marker.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/44924","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=44924"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/44924\/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=44924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=44924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=44924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}