[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Fwd: [pygame] loading images with special characters on file name



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 <rneu2011@xxxxxxxxx>
Date: 2011/2/9
Subject: Re: [pygame] loading images with special characters on file name
To: pygame-users@xxxxxxxx


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 <len-l@xxxxxxxxx>

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 <onpon4@xxxxxxxxx <mailto:onpon4@xxxxxxxxx>>


   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 <rneu2011@xxxxxxxxx <mailto:rneu2011@xxxxxxxxx>>
   *To:* pygame-users@xxxxxxxx <mailto:pygame-users@xxxxxxxx>

   *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?






Attachment: figuras.zip
Description: Zip archive