Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserComment #116

Open
FSofTlpz opened this issue Dec 8, 2023 · 0 comments
Open

UserComment #116

FSofTlpz opened this issue Dec 8, 2023 · 0 comments

Comments

@FSofTlpz
Copy link

FSofTlpz commented Dec 8, 2023

I have a problem with 'UserComment'. Unfortunately we can have the exif byte order 'big endian' or 'little endian'. The UserComment must read/write with the correct byte order (for Unicode).
2 little changes worked for me:
in ExifPropertyFactory.cs, line 72:

                   else if (string.Compare(encstr, "Unicode\0", StringComparison.OrdinalIgnoreCase) == 0)
                       enc = byteOrder == BitConverterEx.ByteOrder.LittleEndian ? 
                                                   Encoding.Unicode : 
                                                   Encoding.BigEndianUnicode;

in ExifExtendedProperty.cs, line 106:

                 else if (mEncoding.EncodingName == "Unicode" ||
                            mEncoding.EncodingName == "Unicode (Big-Endian)")
                    enc = "Unicode\0";

In my code i set explicit the value with Encoding:

           if (data is ExifLibrary.JPEGFile &&
               (data as ExifLibrary.JPEGFile).ByteOrder == BitConverterEx.ByteOrder.BigEndian) {
              data.Properties.Set(ExifTag.UserComment, txt, System.Text.Encoding.BigEndianUnicode);
           } else
              data.Properties.Set(ExifTag.UserComment, txt, System.Text.Encoding.Unicode);

With best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant