question mark is written instead of an UTF-8 character

Started by fast Eddy, December 21, 2024, 07:14:46 AM

Previous topic - Next topic

fast Eddy

I use the python wrapper around the exiftool, like:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from exiftool import ExifToolHelper

images = ["skyblue.png"]
et =  ExifToolHelper()
tag = 'XMP:Creator'
people = "Edwin, Juliëte, Sánder"

with ExifToolHelper() as et:
    et.set_tags(
        images,
        tags={"XMP:Creator": people},
        params=["-P", "-overwrite_original"]
    )

d = et.get_metadata(images)
print('{0}:{1}'.format(tag, d
[o][tag]))

Output:
XMP:Creator:Edwin, Juli?te, S?nder

the output should be:
Output:
XMP:Creator:Edwin, Juliëte, Sánder

What do I have to change in my script to create this?



Phil Harvey

It looks like the Charset setting wasn't correct when the information was written.  See FAQ 10 for details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

They are using PyExiftool, which is using -Stay_Open. Shouldn't writing data be unaffected by character coding when doing this?

@Eddy, if you are on Windows, then FAQ #18, problems with special characters on the Windows command line might be applicable.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

There are various places this could go wrong:

1. If the characters in the script aren't UTF-8

2. If the python wrapper is specifying another -charset for ExifTool

3. If whatever shell you are using to display the final result isn't using UTF-8

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).