<?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: Unicode error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603342#M47151</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will not be the solution due to a number of reasons:&lt;/P&gt;&lt;P&gt;If you use something like &lt;EM&gt;u'lyrlst.workspacePath'&lt;/EM&gt;, then you create a unicode text contains the text &lt;EM&gt;lyrlst.workspacePath&lt;/EM&gt; and not the content of the variable. For that you would have to use &lt;EM&gt;unicode(lyrlst.workspacePath)&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other aspect is combining a normal str with a unicode. In your line there are still some elements that are of type str ("," "\\", "\n", etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen posts where they recommend using the codecs library to write unicode to text file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import codecs
with codecs.open(YourOutputFile, 'w', encoding='utf-8') as f:
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(unicode_text)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please take the time to read this article: &lt;A href="http://www.azavea.com/blogs/labs/2014/03/solving-unicode-problems-in-python-2-7/" title="http://www.azavea.com/blogs/labs/2014/03/solving-unicode-problems-in-python-2-7/" rel="nofollow noopener noreferrer" target="_blank"&gt;Solving Unicode Problems in Python 2.7 | Azavea Labs&lt;/A&gt; It can help to clear thing up for you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:52:13 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-12T01:52:13Z</dc:date>
    <item>
      <title>Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603331#M47140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i am running this code i am getting a Unicode error half way through. Not sure what mxd/layer file name is hanging it up (line 33) on but not sure where to put the fix (line 7 - or if this is the correct fix) either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="unicodeError.JPG" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/119813_unicodeError.JPG" style="width: 620px; height: 69px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

#code adds mxd name and layer path name to text file separated by a comma
arcpy.env.overwriteOutput = True


#def Utf8EncodeArray(oldArray):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #newArray = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; #for element in oldArray:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #if isinstance(element, unicode):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #newArray.append(element.encode("utf-8"))
&amp;nbsp;&amp;nbsp;&amp;nbsp; #else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #newArray.append(element)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #return newArray


path = "////serverpath"
#path2 =
mxdlst = []
txt = open("text file path", 'w')
print "making mxd list"
for root, dirs, files in os.walk(path):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fname in files:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fname.endswith(".mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = root + '\\' + fname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdlst.append(mxd)
del mxd, fname
for mapdoc in mxdlst:
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mapdoc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for df in arcpy.mapping.ListDataFrames(mxd, "*"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyrlst in arcpy.mapping.ListLayers(mxd, "*", df):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyrlst.supports("DATASOURCE"):
&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; txt.write(mapdoc + "," + lyrlst.workspacePath + "\\" + lyrlst.name + "\n")
&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; print "adding" + mapdoc + "," + lyrlst.workspacePath + "\\" + lyrlst.name + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&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; txt.write(mapdoc + "," + lyrlst.name + "\n")
&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; print "adding" + mapdoc + "," + lyrlst.name + "\n"
txt.close()
del mxd, df, lyrlst, mapdoc, mxdlst&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:52:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603331#M47140</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2021-12-12T01:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603332#M47141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the layer name etc?&amp;nbsp; If it contains&amp;nbsp; characters that need to be converted, then you will have to do so&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 22:34:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603332#M47141</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-07-29T22:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603333#M47142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need code to check for that and fix it just not sure where to put it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 23:06:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603333#M47142</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2015-07-29T23:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603334#M47143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;haven't had the unicode issues yet, but apparently, I will have to and one suggestion is to specify encoding at the top of the script with&lt;/P&gt;&lt;P&gt;&lt;SPAN class="go"&gt;# -*- coding: utf-8 -*-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;​but some unicode types should step up since it appears that you have a character that can't be represented by the ASCII chars in the range 0-127&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 23:53:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603334#M47143</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-07-29T23:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603335#M47144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have seen that before. does it work with the # sign in front?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 00:04:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603335#M47144</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2015-07-30T00:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603336#M47145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;apparently that is what is supposed be done, first line.&amp;nbsp; but I seriously haven't played with encoding other than ascii ... I really should given accented characters etc, but so far, haven't had to deal with.&amp;nbsp; My only suggestion is find someone that works with such data and or look at at one of the files and see what characters are present there.&amp;nbsp; Sorry I can't help more, but searching on your error message on GeoNet may turn up more&lt;/P&gt;&lt;P&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 00:23:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603336#M47145</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-07-30T00:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603337#M47146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An interesting article to read would be:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.azavea.com/blogs/labs/2014/03/solving-unicode-problems-in-python-2-7/" title="http://www.azavea.com/blogs/labs/2014/03/solving-unicode-problems-in-python-2-7/" rel="nofollow noopener noreferrer" target="_blank"&gt;Solving Unicode Problems in Python 2.7 | Azavea Labs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And to give an example of what works and fails:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# -*- coding: utf-8 -*-
myText = u"example of únì¢ødë"

# this works:
print myText

# UnicodeEncodeError: 'ascii' codec can't encode character u'\xfa' in position 11: ordinal not in range(128)
print "{0}".format(myText)
# inserting unicode in a str

# This works 
print u"{0}".format(myText)
# inserting unicode into a unicode

# UnicodeEncodeError: 'ascii' codec can't encode character u'\xfa' in position 11: ordinal not in range(128)
print u"{0}".format(myText.decode('utf-8'))
# inserting utf-8 into unicode&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:52:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603337#M47146</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T01:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603338#M47147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what a kludge...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&lt;SPAN class="comment"&gt;# -*- coding: utf-8 -*-&lt;/SPAN&gt;
&lt;OL class="dp-py"&gt;&lt;LI&gt;chars = [unichr(i) for i in range(0,256) if (32 &amp;lt; i &amp;lt; 128) or (i &amp;gt; 161)]&lt;/LI&gt;&lt;/OL&gt;
print "Unicode characters 33-127 and 161-255\n" + ("{:5}"*len(chars)).format(*chars)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unicode characters 33-127 and 161-255&lt;/P&gt;&lt;P&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;amp;&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; /&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp; :&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ?&amp;nbsp;&amp;nbsp;&amp;nbsp; @&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp; C&amp;nbsp;&amp;nbsp;&amp;nbsp; D&amp;nbsp;&amp;nbsp;&amp;nbsp; E&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp; G&amp;nbsp;&amp;nbsp;&amp;nbsp; H&amp;nbsp;&amp;nbsp;&amp;nbsp; I&amp;nbsp;&amp;nbsp;&amp;nbsp; J&amp;nbsp;&amp;nbsp;&amp;nbsp; K&amp;nbsp;&amp;nbsp;&amp;nbsp; L&amp;nbsp;&amp;nbsp;&amp;nbsp; M&amp;nbsp;&amp;nbsp;&amp;nbsp; N&amp;nbsp;&amp;nbsp;&amp;nbsp; O&amp;nbsp;&amp;nbsp;&amp;nbsp; P&amp;nbsp;&amp;nbsp;&amp;nbsp; Q&amp;nbsp;&amp;nbsp;&amp;nbsp; R&amp;nbsp;&amp;nbsp;&amp;nbsp; S&amp;nbsp;&amp;nbsp;&amp;nbsp; T&amp;nbsp;&amp;nbsp;&amp;nbsp; U&amp;nbsp;&amp;nbsp;&amp;nbsp; V&amp;nbsp;&amp;nbsp;&amp;nbsp; W&amp;nbsp;&amp;nbsp;&amp;nbsp; X&amp;nbsp;&amp;nbsp;&amp;nbsp; Y&amp;nbsp;&amp;nbsp;&amp;nbsp; Z&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; a&amp;nbsp;&amp;nbsp;&amp;nbsp; b&amp;nbsp;&amp;nbsp;&amp;nbsp; c&amp;nbsp;&amp;nbsp;&amp;nbsp; d&amp;nbsp;&amp;nbsp;&amp;nbsp; e&amp;nbsp;&amp;nbsp;&amp;nbsp; f&amp;nbsp;&amp;nbsp;&amp;nbsp; g&amp;nbsp;&amp;nbsp;&amp;nbsp; h&amp;nbsp;&amp;nbsp;&amp;nbsp; i&amp;nbsp;&amp;nbsp;&amp;nbsp; j&amp;nbsp;&amp;nbsp;&amp;nbsp; k&amp;nbsp;&amp;nbsp;&amp;nbsp; l&amp;nbsp;&amp;nbsp;&amp;nbsp; m&amp;nbsp;&amp;nbsp;&amp;nbsp; n&amp;nbsp;&amp;nbsp;&amp;nbsp; o&amp;nbsp;&amp;nbsp;&amp;nbsp; p&amp;nbsp;&amp;nbsp;&amp;nbsp; q&amp;nbsp;&amp;nbsp;&amp;nbsp; r&amp;nbsp;&amp;nbsp;&amp;nbsp; s&amp;nbsp;&amp;nbsp;&amp;nbsp; t&amp;nbsp;&amp;nbsp;&amp;nbsp; u&amp;nbsp;&amp;nbsp;&amp;nbsp; v&amp;nbsp;&amp;nbsp;&amp;nbsp; w&amp;nbsp;&amp;nbsp;&amp;nbsp; x&amp;nbsp;&amp;nbsp;&amp;nbsp; y&amp;nbsp;&amp;nbsp;&amp;nbsp; z&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;#127;&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; ª&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; ³&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; ¼&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; Å&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; Î&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; ×&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; à&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; é&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; ò&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; û&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;anything not visible, isn't...can't wait to learn all of them &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:52:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603338#M47147</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T01:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603339#M47148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Dan Patterson:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...one suggestion is to specify encoding at the top of the script with &lt;SPAN class="go"&gt;# -*- coding: utf-8 -*-&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This only applies to literal characters in the python script file itself, not any string variables when the script is run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test_noenc.py&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;somestr = u'über còól'
print somestr&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;test_enc.py&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="typ"&gt;# -*- coding: utf-8 -*-
somestr = u'über còól'
print somestr&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;C:\Temp&amp;gt;python test_noenc.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;&amp;nbsp; File "test_noenc.py", line 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;&lt;SPAN&gt;SyntaxError: Non-ASCII character '\xfc' in file test_noenc.py on line 1, but no encoding declared; see &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://python.org/dev/peps/pep-0263/" target="_blank"&gt;http://python.org/dev/peps/pep-0263/&lt;/A&gt;&lt;SPAN&gt; for details&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;C:\Temp&amp;gt;python test_enc.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;über còól&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:52:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603339#M47148</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-12T01:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603340#M47149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Luke...fixed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 06:17:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603340#M47149</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-07-31T06:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603341#M47150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_1438362117487938 jive_macro_code jive_text_macro" data-renderedposition="8_8_912_0" jivemacro_uid="_1438362117487938"&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;is this how to do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14383621276242367 jive_text_macro" data-renderedposition="50_8_912_16" jivemacro_uid="_14383621276242367"&gt;&lt;P&gt;txt.write(u'mapdoc' + "," + u'lyrlst.workspacePath' + "\\" + u'lyrlst.name' + "\n")&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 17:03:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603341#M47150</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2015-07-31T17:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unicode error</title>
      <link>https://community.esri.com/t5/python-questions/unicode-error/m-p/603342#M47151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will not be the solution due to a number of reasons:&lt;/P&gt;&lt;P&gt;If you use something like &lt;EM&gt;u'lyrlst.workspacePath'&lt;/EM&gt;, then you create a unicode text contains the text &lt;EM&gt;lyrlst.workspacePath&lt;/EM&gt; and not the content of the variable. For that you would have to use &lt;EM&gt;unicode(lyrlst.workspacePath)&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other aspect is combining a normal str with a unicode. In your line there are still some elements that are of type str ("," "\\", "\n", etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have seen posts where they recommend using the codecs library to write unicode to text file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import codecs
with codecs.open(YourOutputFile, 'w', encoding='utf-8') as f:
&amp;nbsp;&amp;nbsp;&amp;nbsp; f.write(unicode_text)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please take the time to read this article: &lt;A href="http://www.azavea.com/blogs/labs/2014/03/solving-unicode-problems-in-python-2-7/" title="http://www.azavea.com/blogs/labs/2014/03/solving-unicode-problems-in-python-2-7/" rel="nofollow noopener noreferrer" target="_blank"&gt;Solving Unicode Problems in Python 2.7 | Azavea Labs&lt;/A&gt; It can help to clear thing up for you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:52:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unicode-error/m-p/603342#M47151</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T01:52:13Z</dc:date>
    </item>
  </channel>
</rss>

