<?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 simple check for field script started giving error message in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/simple-check-for-field-script-started-giving-error/m-p/481030#M16152</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a simple script which checks to see if a field exists in a table.&amp;nbsp; Until a few days ago, I had no trouble with this, but now, when I call this script from within a script, I get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: &amp;lt;unprintable AttributeError object&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.UnicodeEncodeError'&amp;gt;: 'ascii' codec can't encode characters in position 29-37: ordinal not in range(128)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have uninstalled and re-installed ArcGIS Desktop and I'm still getting this error whenever I try to set a variable by running another script as in: var = arcpy.FieldCheck_AgTools(intab, fieldname).&amp;nbsp; Running the script by double clicking it in the toolbox works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas about how to fix this or what's going on?&amp;nbsp; My Layers, tables, fields, etc, do not contain any special characters or spaces.&amp;nbsp; I don't understand why it worked one day and quit working the next.&amp;nbsp; Any input is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Apr 2012 14:55:49 GMT</pubDate>
    <dc:creator>BarbaraCarrigan</dc:creator>
    <dc:date>2012-04-02T14:55:49Z</dc:date>
    <item>
      <title>simple check for field script started giving error message</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/simple-check-for-field-script-started-giving-error/m-p/481030#M16152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a simple script which checks to see if a field exists in a table.&amp;nbsp; Until a few days ago, I had no trouble with this, but now, when I call this script from within a script, I get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: &amp;lt;unprintable AttributeError object&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.UnicodeEncodeError'&amp;gt;: 'ascii' codec can't encode characters in position 29-37: ordinal not in range(128)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have uninstalled and re-installed ArcGIS Desktop and I'm still getting this error whenever I try to set a variable by running another script as in: var = arcpy.FieldCheck_AgTools(intab, fieldname).&amp;nbsp; Running the script by double clicking it in the toolbox works fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas about how to fix this or what's going on?&amp;nbsp; My Layers, tables, fields, etc, do not contain any special characters or spaces.&amp;nbsp; I don't understand why it worked one day and quit working the next.&amp;nbsp; Any input is appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2012 14:55:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/simple-check-for-field-script-started-giving-error/m-p/481030#M16152</guid>
      <dc:creator>BarbaraCarrigan</dc:creator>
      <dc:date>2012-04-02T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: simple check for field script started giving error message</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/simple-check-for-field-script-started-giving-error/m-p/481031#M16153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But your data does contain some "unexpected data". The error message says so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
AttributeError: &amp;lt;unprintable AttributeError object&amp;gt;
&amp;lt;type 'exceptions.UnicodeEncodeError'&amp;gt;: 'ascii' codec can't encode characters in position 29-37: ordinal not in range(128)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;It even tells you where the characters are. It is very easy these days to enter unicode by mistake from the keyboard or a web page cut and paste.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not all Python functions handle unicode as if they were ascii. If you have tried to convert a unicode string that contains a character other than the ascii set then you need to encode/decode the value to an equivalent ascii value. Just doing&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt; str(u'\u0100')
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0100' in position 0: ordinal not in range(128)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;will upset Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; str(u'\u0100'.encode('utf-8'))
'\xc4\x80'&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;And this will probably upset the reader, but it will explain the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what I had to work out to add macrons to a database&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# unicode.py This Python file uses the following encoding: utf-8
import encodings.utf_8_sig
comment = """
&amp;lt;HEAD&amp;gt;
&amp;lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"&amp;gt; 

To make your pages display properly in Unicode, you need to change this to:

&amp;lt;HEAD&amp;gt;
&amp;lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"&amp;gt;

import codecs
f = codecs.open("file","w",encoding='utf-8')
f.write(stuff)
f.close()

"""

##&amp;amp;#256 = A-
##&amp;amp;#274 = E-
##&amp;amp;#298 = I-
##&amp;amp;#332 = O-
##&amp;amp;#362 = U-

##&amp;amp;#257 = a-
##&amp;amp;#275 = e-
##&amp;amp;#299 = i-
##&amp;amp;#333 = o-
##&amp;amp;#363 = u-

dMacron = {
"A" : u'\u0100',
"a" : u'\u0101',
"E" : u'\u0112',
"e" : u'\u0113',
"I" : u'\u012A',
"i" : u'\u012B',
"O" : u'\u014C',
"o" : u'\u014D',
"U" : u'\u016A',
"u" : u'\u016B'
}

f1 = open("e:/project/training/unicode/unicode_sample.txt","w")
print
# read-only f1.encoding # = "utf8"
# print &amp;gt;&amp;gt; f1,dMacron # cannot do this to ascii encoder
mO = u"\N{LATIN CAPITAL LETTER O WITH MACRON}"

word = "Maori".replace("o",dMacron["o"])
print &amp;gt;&amp;gt; f1,word.encode('utf-8')
# PyUnicode.__print__ word.encode('utf-8')

lstKey = dMacron.keys()
lstKey.sort()
for k in lstKey :
print &amp;gt;&amp;gt; f1,dMacron&lt;K&gt;.encode('utf-8'),
print dMacron&lt;K&gt;,
##mA = u'\u0100'
##ma = u'\u0101'
##mE = u'\u0112'
##me = u'\u0113'
##mI = u'\u012A'
##mi = u'\u012B'
##mO = u'\u014C'
##mo = u'\u014D'
##mU = u'\u016A'
##mu = u'\u016B'

# word = "Maori".replace("o",dMacron["o"])

mO = u"\N{LATIN CAPITAL LETTER O WITH MACRON}"
word = "MAORI".replace("O",mO)
print &amp;gt;&amp;gt; f1,word.encode('utf-8')
print word
f1.close()

print "success" &lt;/K&gt;&lt;/K&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I once reinstalled the entire operating system on a Sun 3, including printer drivers when the new postscript printer stopped working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It had stopped because the printer had run out of paper and the Sun driver did not understand postscript error messages. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't ever reinstall a software package when I hit a bug now, life is too short.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:13:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/simple-check-for-field-script-started-giving-error/m-p/481031#M16153</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T21:13:36Z</dc:date>
    </item>
  </channel>
</rss>

