<?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: How to handle special characters? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236176#M18380</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You're going to need to use decode() to get a unicode object, but you'll need to know the encoding to supply the argument it needs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Mar 2015 16:24:03 GMT</pubDate>
    <dc:creator>BruceHarold</dc:creator>
    <dc:date>2015-03-04T16:24:03Z</dc:date>
    <item>
      <title>How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236172#M18376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I developed some arctoolboxes using python code to do some process on shapefiles. Some of shapefiles fileds contain special Characters as é. at each time my script crashed when it meet those characters in fiel values. What I did until now is just replacing é by e as an example. Some time, it is a lot of work to find/replace all the special characters. I looked on the web for solutions to this problem but unfortunatly, i did not find anything to use without find/replace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I am wondering if there is a solution for this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 14:30:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236172#M18376</guid>
      <dc:creator>SaidAkif</dc:creator>
      <dc:date>2015-03-04T14:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236173#M18377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What kind of error do you get, could you post a small snippet to demonstrate it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One thing that will fail is for instance getting a row value and explicitly converting it to str. This can be solved by removing that conversion.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;x = str(row[0]) # fails
x = row[0]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # correct
print(type(x))&amp;nbsp; # will print: &amp;lt;type 'unicode'&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have any special characters in the source file itself, you could add this line at the top to specify it's using UTF-8&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080; font-style: italic;"&gt;# -*- coding: utf-8 -*-&lt;/SPAN&gt;
&lt;SPAN style="color: #808080; font-style: italic;"&gt;x = u"éè"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236173#M18377</guid>
      <dc:creator>BerendVeldkamp</dc:creator>
      <dc:date>2021-12-11T11:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236174#M18378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Berend is correct, we'll need to see your code to help, but what is happening is your shapefile is using a character encoding which you'll need to know in order to fix your processing, or you'll need to copy the data to a geodatabase so it is in a known encoding - UTF-8.&amp;nbsp; If there is a .cpg file with your shapefile then you can read it to get the encoding, otherwise you'll have to guess, which may get frustrating.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 16:05:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236174#M18378</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2015-03-04T16:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236175#M18379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;most of the time the special character are related to french languge. I know the list of those specil characters&lt;/P&gt;&lt;P&gt;Now, if I do : x=u'all specil characters', how i can use x in my code?&lt;/P&gt;&lt;P&gt;sorry i am began in python&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 16:21:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236175#M18379</guid>
      <dc:creator>SaidAkif</dc:creator>
      <dc:date>2015-03-04T16:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236176#M18380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You're going to need to use decode() to get a unicode object, but you'll need to know the encoding to supply the argument it needs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 16:24:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236176#M18380</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2015-03-04T16:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236177#M18381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Bruce: That actually depends, and may even be unicode (utf-8): See &lt;A href="http://support.esri.com/cn/knowledgebase/techarticles/detail/21106" title="http://support.esri.com/cn/knowledgebase/techarticles/detail/21106"&gt;21106 - Read and write shapefile and dBASE files encoded in various code pages&lt;/A&gt;. I think that if the dbf is in a specific codepage (not unicode), Python wouldn't break, it would merely display wrong characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That said, without seeing the actual code and the data it is all rather speculative.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 17:09:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236177#M18381</guid>
      <dc:creator>BerendVeldkamp</dc:creator>
      <dc:date>2015-03-04T17:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle special characters?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236178#M18382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your input&lt;/P&gt;&lt;P&gt;I want just to underline that I faced this problem when I used SelectByAttributes. I have to keep my content of fields as they are without any changes. I believe that I used the decode() but it did not work. Perhaps i used it in the wrong way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2015 17:17:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-handle-special-characters/m-p/236178#M18382</guid>
      <dc:creator>SaidAkif</dc:creator>
      <dc:date>2015-03-04T17:17:17Z</dc:date>
    </item>
  </channel>
</rss>

