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
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
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.
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 ;)
Thanks a lot!
:)
Life is god in special when you get quick and GOOD answers
Attila