It is currently Fri Jul 03, 2026 11:01 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Working with unicode filenames
PostPosted: Sat Oct 30, 2021 8:25 pm  (#1) 
Offline
GimpChat Member

Joined: Oct 10, 2014
Posts: 36
I like to share with you my experience in handling unicode pathnames. I had trouble with this

import os
image_filename = pdb.gimp_image_get_filename(image)
(fileroot,filename)=os.path.split(image_filename)
fileroot+="\\output"
if not os.path.isdir(fileroot):
os.makedirs(fileroot)

The code would fail if the filename contains unicode. The simple fix is to add a unicode conversion right after the image_get_filename and everything works.

import os
image_filename = pdb.gimp_image_get_filename(image)
image_filename = unicode(image_filename, "utf-8", errors="ignore")
(fileroot,filename)=os.path.split(image_filename)
fileroot+="\\output"
if not os.path.isdir(fileroot):
os.makedirs(fileroot)

I hope this is useful info to others.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group