[Posting the same question on stackoverflow.com]
Hello.
We are developing a camera application using AVFoundation on iOS.
I'm trying to add an EXIF UserComment to the photo I took, but it works well with one byte strings such as English, but when I try to add a two-byte string in Japanese, it cuts off in the middle.
In the code below, all characters have been successfully added to UserComment.
NSString *UserComment = @"Can I set Exif UserComment String in such a way? I cannot understand Japanese Characters are not accepted.";
[EXIFDictionary setObject:UserComment forKey:(__bridge NSString *) kCGImagePropertyExifUserComment];
The following code could be added to UserComment, but could only be added halfway.
UserComment=@"You can't say that, you can't do that, you have to have a shower.Just give up and do your job.Screaming. Did you see?Yes.";
[EXIFDictionary setObject:UserComment forKey:(__bridge NSString *) kCGImagePropertyExifUserComment];
I checked with exiftool and found that the following strings were added to UsrComment
You can't say that, you can't say no, you can't say no.Just
Is this an SDK bug?If anyone knows the cause or how to avoid it, could you tell me?
ios exif
I think it is a bug that occurs on iOS7.(I don't have the actual machine, so I can't try it.)
Judging from the location where the string is broken and how to deal with it, I think there is a bug in calculating the number of characters.
In each example, the string is cut in exactly half (by counting characters, not bytes), so it matches the "padding ASCII characters with +2 characters" solution.
Note:
■[iPhone Programming]Read and write Exif information in JPEG files
From the comments section.(Comments about tools)
iOS 6.1 is OK, but iOS 7 will run out of characters.
If you pad ASCII characters with the number of characters +2, you can write the characters themselves, but 0x00 is embedded in the padded statement.
This page also states that you have seen similar symptoms.
© 2024 OneMinuteCode. All rights reserved.