<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script file not encoded correctly with ANSI or utf8 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705856#M54632</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One of the 2 to 3 things you need to remember... strings are no more... strings are now Unicode and way more character sets are now supported.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Jan 2019 18:36:59 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-01-29T18:36:59Z</dc:date>
    <item>
      <title>Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705853#M54629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We've been struggling to get a python script running that originally came from ESRI: it's a maintenance script for a vector tile basemaps.&amp;nbsp; The script hasn't worked for us and the subject line above is the response we got from ESRI tech support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below are identical lines of code:&amp;nbsp; Line one is what we see in IDLE while Line 2 is what we see in Spyder.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;tpk &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;  r'â€ªC&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;\Users\jaburton\Documents\ArcGIS\Projects\VectorBasemap\VectorTilePackage&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;vtpk

tpk &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;  r&lt;SPAN class="string token"&gt;'‪C:\Users\jaburton\Documents\ArcGIS\Projects\VectorBasemap\VectorTilePackage.vtpk'&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When we run it as a stand-alone script in Spyder it bails out with this error:&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/436061_Spyder_TileError.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So its' not seeing the path where the variable tpk points to. The source of the raw text string is a copy and paste from a Windows Explorer window: pretty standard practice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do we convince Spyder all is good?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:39:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705853#M54629</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-12T05:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705854#M54630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at the very top of all scripts&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 18:27:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705854#M54630</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-01-29T18:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705855#M54631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;awesome.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edited moments later:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan- it already appears at the top of the script; Spyder does it for you...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 18:32:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705855#M54631</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-01-29T18:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705856#M54632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One of the 2 to 3 things you need to remember... strings are no more... strings are now Unicode and way more character sets are now supported.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 18:36:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705856#M54632</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-01-29T18:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705857#M54633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just ran it again with&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;# -*- coding: utf-8 -*- as line 1.&amp;nbsp; Errors out with the same problem....&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 18:43:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705857#M54633</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-01-29T18:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705858#M54634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;even worse... you didn't raw encode or use forward slashes..&lt;/P&gt;&lt;P&gt;Our class motto, when it comes to file paths&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;"C:\Users\Is\For\Losers"&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File "&amp;lt;ipython-input-1-d259788efdf0&amp;gt;", line 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\Users\Is\For\Losers"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;BR /&gt;SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't use 'Users'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 18:57:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705858#M54634</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-01-29T18:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705859#M54635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's working now, not sure what the hicup was....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jan 2019 19:24:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705859#M54635</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2019-01-29T19:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Python script file not encoded correctly with ANSI or utf8</title>
      <link>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705860#M54636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quick hack to strip out any non-ascii characters:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;input &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'C:/temp/test.py'&lt;/SPAN&gt;
output &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'C:/temp/test_edited.py'&lt;/SPAN&gt;

input &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;output&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'w'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; outf&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    outf&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;write&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;encode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'ascii'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'ignore'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;decode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;repr&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;input&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;repr&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;output&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;"tpk =  r'â€ªC:\\Users\\jaburton\\Documents\\ArcGIS\\Projects\\VectorBasemap\\VectorTilePackage.vtpk'\n"
"tpk =  r'C:\\Users\\jaburton\\Documents\\ArcGIS\\Projects\\VectorBasemap\\VectorTilePackage.vtpk'\n"
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-file-not-encoded-correctly-with-ansi/m-p/705860#M54636</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-12T05:39:40Z</dc:date>
    </item>
  </channel>
</rss>

