Post Reply 

Accented characters wihtin "text string" prevent script from loading

Aug 28, 2014, 04:16
Post: #1
Accented characters wihtin "text string" prevent script from loading
Hi all. New to GIMP scripting; I've been reading/playing around for a couple of hours now but I also have spent an embarrassing amount of time trying to figure this one out (at first I thought I made syntax mistakes).

In my learning efforts, I inspired myself from the tiniest demo script available online and customized it along for my own purposes. In a nutshell, when an accented character appears in a "text string" (within double quotes), a working script goes completely AWOL and does not show up upon starting the program.

Accented characters are common in the French language, and I presumed string handling was meant to be pretty robust in the second decade of the 21st century, so I was a bit baffled by this.

Does this repeat on other Win8 machines, GIMP 2.8.14? Thanks for letting me know.

OFFENDING SCRIPT (4 problematic characters present; changing é to e, à to a and û to u makes the script working again):
#!/usr/bin/env python

from gimpfu import *

# create an output function that redirects to gimp's Error Console
def gprint( text ):

# our script
def onefromtwo(image, drawable, strog, strod) :

gprint("Make one from two")
gprint("You sent me this text: "+strog)
gprint("You also sent me this text: "+strod)

# This is the plugin registration function
"Convertit deux images",
"Convertit deux images en une image",
"Sébastien à la maison",
"Août 2014",
(PF_STRING, 'string_og', 'Chemin\\fichier image 1', 'C:\\Photos\\1.jpg'),
(PF_STRING, 'string_od', 'Chemin\\fichier image 2', 'C:\\Photos\\2.jpg')

Find all posts by this user
Quote this message in a reply
Aug 28, 2014, 15:37
Post: #2
RE: Accented characters wihtin "text string" prevent script from loading
Oh, I am so grateful! Thank you for the quick response and primer tips. As you could guess I am new to Python. Also, I am unfamiliar on how external scripting is managed within an application such as GIMP so your insight was invaluable.

(Aug 28, 2014 07:08)ofnuts Wrote:  For French, use either of these:
# -*- coding: iso-8859-15 -*-
# -*- coding: utf-8 -*-
depending of course on how the file is encoded (your text editor should tell you, iso-8859-15 likely given the error message below).

Both coding schemes resolve the issue.

PF_FILENAME is exactly what I need, thanks for the suggestion. Idea
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Loading PythonFu Plugin: ImportError for .../python/ (GIMP 2.8.22/OSX/Py2.7.9) joroek 1 123 Jul 11, 2017 07:26
Last Post: ythgilb
  Need help in running a gui script-fu via command line eyalzek 2 226 Oct 4, 2014 14:05
Last Post: eyalzek
  Color menuitems in script or plugin Barbie 4 385 Sep 29, 2014 09:51
Last Post: paynekj
  script-fu ok in gimp, not in commad line dominique 1 264 Sep 28, 2014 03:18
Last Post: dominique
  Script fu and Color to alpha john 4 397 Sep 20, 2014 08:46
Last Post: rich2005

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS