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 ):
pdb.gimp_message(text)
return

# 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)
return

# This is the plugin registration function
register(
"onefromtwo_script",
"Convertit deux images",
"Convertit deux images en une image",
"Sébastien",
"Sébastien à la maison",
"Août 2014",
"<Image>/MyScripts/Maker...",
"*",
[
(PF_STRING, 'string_og', 'Chemin\\fichier image 1', 'C:\\Photos\\1.jpg'),
(PF_STRING, 'string_od', 'Chemin\\fichier image 2', 'C:\\Photos\\2.jpg')
],
[],
onefromtwo,
)

main()
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:
Code:
# -*- 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
  Request for script chlebna 1 128 Sep 13, 2017 09:35
Last Post: ythgilb
  Request for script - Guillotine + Watermark sunslick 1 194 Sep 4, 2017 08:51
Last Post: ythgilb
  Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer Bertholomäus 2 182 Aug 31, 2017 14:32
Last Post: Bertholomäus
  How to modify this script-fu? Zakary81 1 152 Aug 23, 2017 12:48
Last Post: paynekj
  Loading PythonFu Plugin: ImportError for .../python/gimp.so (GIMP 2.8.22/OSX/Py2.7.9) joroek 1 256 Jul 11, 2017 07:26
Last Post: ythgilb

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS