ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: attila on February 05, 2015, 09:31:36 AM

Title: special characters How to add copyright symbol?
Post by: attila on February 05, 2015, 09:31:36 AM

Trying to ad copyright symbol using

use Image::ExifTool qw(:Public);


$text=chr(0xa9);

$AdditionalModelInformation  =$text."2015 Attila Benko Copyright,All rights reserved";

my $exifTool = new Image::ExifTool;


my $info = ImageInfo($info);
my @files = File::Find::Rule->file
                               ->name("2.nef")
                               ->in('c:\perl64\eg');

$exifTool->SetNewValue(AdditionalModelInformation  => $AdditionalModelInformation);
$exifTool->WriteInfo($a);


the problem is instead of copyright symbol ? is added

Please advise

Thank you fro support.

Attila
Title: Re: special characters How to add copyright symbol?
Post by: Hayo Baan on February 05, 2015, 10:20:04 AM
Your problem is that while chr(0xa9) is indeed the Unicode code point for the copyright symbol, your string is not interpreted as Unicode (UTF-8). In order for this to work you'll have encode the character as utf-8 yourself. This can be done in multiple ways, e.g., like so:
use Encode;
$AdditionalModelInformation = encode_utf8(chr(0xa9) . ' 2015 Attila Benko, All rights reserved');


Hope this helps,
Hayo
Title: Re: special characters How to add copyright symbol?
Post by: Phil Harvey on February 05, 2015, 10:35:16 AM
Or you could let ExifTool do the recoding for you:

$exifTool->Options(Charset => 'Latin');
$exifTool->SetNewValue(AdditionalModelInformation => "\xa9 2015");


or you could specify the UTF-8 encoding to begin with (© is "\xc2\xa9" as UTF-8):

$exifTool->SetNewValue(AdditionalModelInformation => "\xc2\xa9 2015");

- Phil

P.S. Also note that you don't need to call ImageInfo() before you call WriteInfo() unless you want to extract some information for another purpose.
Title: Re: special characters How to add copyright symbol?
Post by: Hayo Baan on February 05, 2015, 10:37:50 AM
Quote from: Phil Harvey on February 05, 2015, 10:35:16 AM
Or you could let ExifTool do the recoding for you:

$exifTool->Options(Charset => 'Latin');
$exifTool->SetNewValue(AdditionalModelInformation => "\xa9 2015");


Phil's solution is of course better/easier ;)
Title: Re: special characters How to add copyright symbol?
Post by: attila on February 05, 2015, 11:20:12 AM
Thanks a lot!
:)
Life is god in special when you get quick and GOOD answers

Attila