<?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 window - encoding problem/special characters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595664#M46634</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Picked an idea for this off stack overflow (&lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/9040618/convert-a-string-u05d9-u05d7-u05e4-u05d9-u05dd-to-its-unicode-character-in-py?rq=1" rel="nofollow noopener noreferrer" target="_blank"&gt;link&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy,json
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print json.dumps(lyr.name, ensure_ascii=False)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:34:26 GMT</pubDate>
    <dc:creator>BenHolmes</dc:creator>
    <dc:date>2021-12-12T01:34:26Z</dc:date>
    <item>
      <title>Python window - encoding problem/special characters</title>
      <link>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595663#M46633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do we best handle special characters when using the python window? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have this code: &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy
&amp;gt;&amp;gt;&amp;gt; mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd):
...&amp;nbsp; print lyr&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which prints out my layers without special characters, but when it gets to the first layer with a special character in the name I get this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 3, in &amp;lt;module&amp;gt;
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 3: ordinal not in range(128)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, how can I get around this problem? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Using 10.1, Build 3035)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 08:02:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595663#M46633</guid>
      <dc:creator>StefanHaglund1</dc:creator>
      <dc:date>2012-10-04T08:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python window - encoding problem/special characters</title>
      <link>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595664#M46634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Picked an idea for this off stack overflow (&lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/9040618/convert-a-string-u05d9-u05d7-u05e4-u05d9-u05dd-to-its-unicode-character-in-py?rq=1" rel="nofollow noopener noreferrer" target="_blank"&gt;link&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy,json
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print json.dumps(lyr.name, ensure_ascii=False)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:34:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595664#M46634</guid>
      <dc:creator>BenHolmes</dc:creator>
      <dc:date>2021-12-12T01:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python window - encoding problem/special characters</title>
      <link>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595665#M46635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank's Ben,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That was easy enough!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 12:10:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-window-encoding-problem-special-characters/m-p/595665#M46635</guid>
      <dc:creator>StefanHaglund1</dc:creator>
      <dc:date>2012-10-04T12:10:45Z</dc:date>
    </item>
  </channel>
</rss>

