Oli01

Codepage-Question

Discussion created by Oli01 on Nov 26, 2012
Hello,
we are running two ArcGIS-ArcView in our company. One of them I recently updated to 10.1 the other one still is 10.0.

For some years I use a python-script which can delete all fields in a feature layer except the fields I select when running the tool. Now I get suddenly Problems with field names containing special (german) letters like ö, ä, ü.
After some testing I found out that it had to do with the string containing the names of the fields which is committed from the toolbox to the python-script.
So I run the following script in ArcGIS 10.0  an the same script (same toolbox, same FC) on ArcGIS 10.1:

try:
    aString = sys.argv[2].decode("utf-8")  
except:
    gp.addMessage("utf-8 malfunction")
    try:
        aString = sys.argv[2].decode("cp1252")
    except:
        gp.addError("cp1252 malfunction")
    else:
        gp.addMessage("aString convert to Unicode: cp1252 OK!")
else:
    gp.addMessage("aString convert to Unicode: utf-8 OK!")
   

Result:
- In ArcGIS 10.1  I get the message "aString convert to Unicode: utf-8 OK!"
- In ArcGIS 10.0  I get the messages:
       "utf-8 malfunction"
       "aString convert to Unicode: cp1252 OK!"


So it seems to me that the string which contains the name of the fields is utf-8 coded when passed from the ArcGIS 10.1 - toolbox to the python-script and it is cp1252 coded when passed from the ArcGIS 10.0 - toolbox to the python-script.

Can anybody explain this? Did they change something in the codepage the toolbox uses?
The answer will help me to estimate how much this will take effect on other scripts.

Thank you,
Oliver

Outcomes