Problem getting a file pathname with tkFileDialog

Tim Daneliuk tundra at tundraware.com
Wed Nov 8 21:59:38 CET 2006


Sefyroth wrote:
> Thanks,
> 
> but I get this error when I try this.
> 
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
> position 12: ordinal not in range(128)
> 
>  I had encountered it with the askdirectory method as well. Is there an
> easy way to bypass this?
> 
> Thanks again

I believe you are running into a directory or file name that has
non-ascii characters in it.  Python as shipped is set up to
deal with ascii as its native encoding format.  You can change
this by editing the "site.py" file - look in the Lib directory
in your python installation.  Look for this code:

-------------------------------
def setencoding():
     """Set the string encoding used by the Unicode implementation.  The
     default is 'ascii', but if you're willing to experiment, you can
     change this."""
     encoding = "ascii" # Default value set by _PyUnicode_Init()
     if 0:
         # Enable to support locale aware default string encodings.
         import locale
         loc = locale.getdefaultlocale()
         if loc[1]:
             encoding = loc[1]
-------------------------------



Change the "if 0:" to "if 1:" and see if that doesn't fix the problem.



-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the Python-list mailing list