<?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 resolve encoding errors in python geoprocessing? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/how-to-resolve-encoding-errors-in-python/m-p/194016#M6624</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found the answer: The problem comes from logger_module.debug(str(strInsert)) I deleted str() and everything runs correctly now with logger_module.debug(strInsert)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any idea why it worked in Eclipse but not in ArcGIS Server?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Sep 2013 12:25:59 GMT</pubDate>
    <dc:creator>ab1</dc:creator>
    <dc:date>2013-09-06T12:25:59Z</dc:date>
    <item>
      <title>How to resolve encoding errors in python geoprocessing?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-resolve-encoding-errors-in-python/m-p/194015#M6623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a simple python script that reads a string from a text file and inserts it into an Oracle database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I run the script with Eclipse using Pydev plugin I get no error and the message is inserted into database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I run the script using an ArcGIS geoprocessing service (using a toolbox), I get the following error in the logs, and no insertion is performed into database:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;[06/09/2013-10:30:39.380] ERROR - APPLICATION &amp;lt;module&amp;gt;(&amp;lt;type 'exceptions.UnicodeEncodeError'&amp;gt;, UnicodeEncodeError('ascii', u"INSERT INTO APPLI.ALERT (ID_ALERT,MESSAGE,TYPE_ALERT) values(1617.0,q'[Les coordonn\xe9es ne sont pas correctes\n]',3)", 94, 95, 'ordinal not in range(128)'))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;try: &amp;nbsp;&amp;nbsp;&amp;nbsp; msg=open("myFile.log", 'r') &amp;nbsp;&amp;nbsp;&amp;nbsp; a=msg.read(20)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; strInsert = "INSERT INTO&amp;nbsp; APPLI.ALERT(ID_ALERT,MESSAGE,TYPE_ALERT) values(1625.0,'"+a.replace('\"','').decode('utf-8')+"',3)" &amp;nbsp;&amp;nbsp;&amp;nbsp; logger_module.debug(str(strInsert)) &amp;nbsp;&amp;nbsp;&amp;nbsp; SdeExecuteSQL(CONNEXION_FILE,strInsert ) except: &amp;nbsp;&amp;nbsp;&amp;nbsp; python_error_handler()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I open myFile.log with Notepad++ the encoding is ANSI as UTF-8.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any hint?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 09:20:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-resolve-encoding-errors-in-python/m-p/194015#M6623</guid>
      <dc:creator>ab1</dc:creator>
      <dc:date>2013-09-06T09:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve encoding errors in python geoprocessing?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/how-to-resolve-encoding-errors-in-python/m-p/194016#M6624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found the answer: The problem comes from logger_module.debug(str(strInsert)) I deleted str() and everything runs correctly now with logger_module.debug(strInsert)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you have any idea why it worked in Eclipse but not in ArcGIS Server?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Sep 2013 12:25:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/how-to-resolve-encoding-errors-in-python/m-p/194016#M6624</guid>
      <dc:creator>ab1</dc:creator>
      <dc:date>2013-09-06T12:25:59Z</dc:date>
    </item>
  </channel>
</rss>

