<?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 Rename layer with unsupported signs in a mxd via python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432328#M33996</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does someone have a code example?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Oct 2014 07:43:57 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2014-10-16T07:43:57Z</dc:date>
    <item>
      <title>Rename layer with unsupported signs in a mxd via python?</title>
      <link>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432328#M33996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does someone have a code example?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 07:43:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432328#M33996</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-10-16T07:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename layer with unsupported signs in a mxd via python?</title>
      <link>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432329#M33997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14134582988139372" jivemacro_uid="_14134582988139372"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;import os&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;
&lt;P&gt;for lyr in arcpy.mapping.ListLayers(mxd):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Layer: " + lyr.name + "&amp;nbsp; Source: " + lyr.dataSource)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for lyr in arcpy.mapping.ListLayers(mxd):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrname = str(lyr.name)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyrname&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrname_replaced = lyrname.replace(" ","_")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = lyrname_replaced&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(lyrname_replaced)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;arcpy.RefreshTOC()&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;leads to this error:&lt;/P&gt;&lt;P&gt;File "R:\Karto\zGIS\Python\RenameLayerinMxd.py", line 16, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyrname = str(lyr.name)&lt;/P&gt;&lt;P&gt;UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 3: ordinal not in range(128)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432329#M33997</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-10-16T11:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename layer with unsupported signs in a mxd via python?</title>
      <link>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432330#M33998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lyrname.encode('utf-8')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This leads to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)&lt;/P&gt;&lt;P&gt;???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:40:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432330#M33998</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-10-16T11:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rename layer with unsupported signs in a mxd via python?</title>
      <link>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432331#M33999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right solution is:&lt;/P&gt;&lt;P&gt;lyrname.decode('utf-8')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 11:53:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rename-layer-with-unsupported-signs-in-a-mxd-via/m-p/432331#M33999</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-10-16T11:53:15Z</dc:date>
    </item>
  </channel>
</rss>

