Hi Rodolfo,

Yes, setting the file system encoding for your Python installation is the best solution. Pygame uses this value to encode file names. In theory the source file encoding can differ from the file system encoding. But I cannot get it to work on Windows. Maybe it will work on Linux. This could be a bug. Thanks for pointing out that file system encoding must be set on Windows for non-ascii file names.

Lenard Lindstrom

On 09/02/2011 4:49 PM, Rodolfo Neu wrote:
Hi,
I hope that find a solution:
You have to create a Python module named *sitecustomize.py*, with the lines:
*import sys
sys.setfilesystemencoding('utf-8')*
Now my program is working again.
I found this solution in
http://diveintopython.org/xml_processing/unicode.html

Do you believe that it is the best one?
Thank for any comments
Bye
---------- Forwarded message ----------
From: *Rodolfo Neu* <[email protected] <mailto:[email protected]>>
Date: 2011/2/9
Subject: Re: [pygame] loading images with special characters on file name
To: [email protected] <mailto:[email protected]>


I had pygame-1.9.1.win32-py3.1
According to your advice I installed pygame-1.9.2pre.win32-py3.1
but the problem remains.


here is my code (sending also an attached zip with the images)



#!/usr/bin/python
# -*- coding: utf-8  -*-
import os, pygame

def loadImage(fullname):
    try:
        surface = pygame.image.load(fullname)
        print ("image loaded=", fullname)
    except:
        print( 'Cannot load image:', fullname)

loadImage(os.path.join("figuras", "carro.jpeg"))
loadImage(os.path.join("figuras", "maçã.jpeg")) #problem
loadImage(os.path.join("figuras", "árvore.jpeg")) #problem
loadImage(os.path.join("figuras", "canetas.jpeg"))



2011/2/9 Lenard Lindstrom <[email protected] <mailto:[email protected]>>

    Hi,

    Which version of Pygame. Proper Unicode file name handling was
    added to 1.9.2. Before that only enough Unicode support was added
    to Pygame so it would build and run in Python 3.

    Lenard Lindstrom


    On 08/02/11 12:10 PM, Rodolfo Neu wrote:

        I just tried it but the problem remains.
        Thank you.

        2011/2/8 Julian Marchant <[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>>


           I doubt that this is related to your problem, but since you're
           using Python 3, shouldn't that shebang be "#!/usr/bin/python3"?

------------------------------------------------------------------------
           *From:* Rodolfo Neu <[email protected]
        <mailto:[email protected]> <mailto:[email protected]
        <mailto:[email protected]>>>
           *To:* [email protected] <mailto:[email protected]>
        <mailto:[email protected] <mailto:[email protected]>>

           *Sent:* Tue, February 8, 2011 1:41:32 PM
           *Subject:* [pygame] loading images with special characters
        on file
           name

           Hi,
           After installing Python 3.1.3, I have problems loading images
           whose file name contains special characters, like ã and ç

           Pygame.image.load doesn't work even with:
           #!/usr/bin/python
           # -*- coding utf-8 -*-


           Any help, please?







Reply via email to