<?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: using unicode character in Python file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474905#M37202</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I I tried all of above does not seem to work out, maybe because I am using PyScripter 2.6. Eventually I worked out by the following:&lt;/P&gt;&lt;P&gt;open python file with IDE and add degree symbol to the file when save the IDE prompt to add # -*- coding: cp1252 -*- to the file, click Edit button, the this line was added to the first line and save.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it works!!&lt;/P&gt;&lt;P&gt;Thank you everyone in this discussion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Jul 2016 00:15:23 GMT</pubDate>
    <dc:creator>Dave_J_Zhang</dc:creator>
    <dc:date>2016-07-09T00:15:23Z</dc:date>
    <item>
      <title>using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474897#M37194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to develop a python script tool. In this python file I need to use Unicode character like the following:&lt;/P&gt;&lt;P&gt;input_X.replace("°","&amp;nbsp; "), which intended to replace degree symbol with space, for the purpose of degree minute seconds input. but when I save the python file and reopen again, the file could not recognize the degree symbol and become "?".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have a way to solve this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jul 2016 21:46:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474897#M37194</guid>
      <dc:creator>Dave_J_Zhang</dc:creator>
      <dc:date>2016-07-07T21:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474898#M37195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are using python 2.7 so put this at the top of your script, you have a unicode issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# -*- coding: UTF-8 -*-
&amp;gt;&amp;gt;&amp;gt; a = "°"
&amp;gt;&amp;gt;&amp;gt; a
'°'
&amp;gt;&amp;gt;&amp;gt; b = "temperature "+a
&amp;gt;&amp;gt;&amp;gt; b
'temperature °'
&amp;gt;&amp;gt;&amp;gt; c = b.replace(a,"too cold")
&amp;gt;&amp;gt;&amp;gt;
&amp;gt;&amp;gt;&amp;gt; c
'temperature too cold'&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:59:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474898#M37195</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T20:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474899#M37196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well this works. If you make the degree symbol in a text file, say "degreetest.txt" and read it in it displays it fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;import sys, os&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;# Open the input file&amp;nbsp; *&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;try:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp; intemplate = open("C:/data/degreetest.txt", "r")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;except IOError:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "screwup1"&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;# Read line.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;try:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = intemplate.readline()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;except IOError:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "screwup2"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print x&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;intemplate.close()&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;sys.exit("Finto")&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;also.....&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Try this:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;import unicodedata&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;b = unicodedata.lookup('DEGREE SIGN')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;print b&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;and that will get your degree sign. So you can generate it in the script for use.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 15:12:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474899#M37196</guid>
      <dc:creator>PaulHacker2</dc:creator>
      <dc:date>2016-07-08T15:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474900#M37197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmmmm&amp;nbsp; no need for reading from a file, at least in Canada&lt;/P&gt;&lt;P&gt;if loaded and compiled into a script called Canada.py&amp;nbsp; you will see that it is the utf-8 that is important if using python 2.7.&amp;nbsp; In python 3.x Unicode support is enforced and the concept of a string is a bit fuzzy since everything is generally Unicode or byte.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# -*- coding: UTF-8 -*-&lt;/P&gt;&lt;P&gt;import sys,os&lt;/P&gt;&lt;P&gt;script = os.path.basename(sys.argv[0]).split(".")[0]&lt;/P&gt;&lt;P&gt;a = "°" &lt;/P&gt;&lt;P&gt;print("Ehhh?... a {} of confusion? but not in {}".format(a, script))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 16:18:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474900#M37197</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-08T16:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474901#M37198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I find typing a&amp;nbsp; 'u' to specify a Unicode string helpful:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14680033619436144 jive_text_macro" data-renderedposition="60_8_1332_16" jivemacro_uid="_14680033619436144"&gt;&lt;P&gt;input_X.replace(u'°',' ')&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 18:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474901#M37198</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2016-07-08T18:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474902#M37199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Randy... prepare for python 3.x, there is no more need to u stuff, u'know' &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 19:38:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474902#M37199</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-08T19:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474903#M37200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been watching the clock: &lt;A href="https://community.esri.com/thread/177766"&gt;python 2.7 countdown...&lt;/A&gt; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 20:48:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474903#M37200</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2016-07-08T20:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474904#M37201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;posted a new link there just today... I will give you a direct link to it to save you some time&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/docs/DOC-8359"&gt;Python and ArcGIS Pro 1.3 : Conda&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 22:22:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474904#M37201</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-08T22:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474905#M37202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I I tried all of above does not seem to work out, maybe because I am using PyScripter 2.6. Eventually I worked out by the following:&lt;/P&gt;&lt;P&gt;open python file with IDE and add degree symbol to the file when save the IDE prompt to add # -*- coding: cp1252 -*- to the file, click Edit button, the this line was added to the first line and save.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it works!!&lt;/P&gt;&lt;P&gt;Thank you everyone in this discussion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jul 2016 00:15:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474905#M37202</guid>
      <dc:creator>Dave_J_Zhang</dc:creator>
      <dc:date>2016-07-09T00:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: using unicode character in Python file</title>
      <link>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474906#M37203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that is what I suggested way up at the top... whether you do it command line or in a script you need the utf-8 designation, no need for others for a single character.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jul 2016 00:22:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-unicode-character-in-python-file/m-p/474906#M37203</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-09T00:22:52Z</dc:date>
    </item>
  </channel>
</rss>

