How to pass the Unicode parameters to ExifTool via .NET

Started by Archive, May 12, 2010, 08:54:39 AM

Previous topic - Next topic

Archive

[Originally posted by murat on 2009-08-13 08:24:49-07]

Hello Phil and ExifTool community,

Does anyone can help me to pass the Unicode values to EXIFTool via .NET.

I use the following code to change IPTC:Headline of the image

Code:
 Process process = null;
  ProcessStartInfo psi = new ProcessStartInfo();
  psi.FileName = @"exifTool.exe";
  psi.Arguments = "-overwrite_original_in_place -iptc:codedcharacterset=utf8
-iptc:headline="some headline" a1.jpg";

  psi.UseShellExecute = false;
//  psi.RedirectStandardInput = true;
  psi.WindowStyle = ProcessWindowStyle.Normal;
  psi.CreateNoWindow = true;

  try
  {
    Process.Start(psi);
  }
  catch (Exception e)
  {
    throw new ApplicationException("..."):
  }

But it works for latin characters only. NET's process.StandardInput.Encoding is closed for modifying and I am unable to change it.

 I'll will be appreciated for any advice

--

Murat

Archive

[Originally posted by ce on 2009-08-20 12:20:41-07]

Hi Murat,

it appears you want to write some text in UTF-8 format into the IPTC headline. Unfortunately this is not possible using the command line API on windows due to some restrictions with unicode string handling and the perl binary.

It is unclear to me why you are trying to redirect standard input at the same time. It is not possible to influence command line parsing this way.

Basically there are two solutions for writing unicode: first, save all unicode text to an arg file and then feed that argfile into ExifTool. The second solution would be to write the contents of the argfile directly into stdin. You need to make sure there is only one kind of encoding used in the argfile/stdin, so dont combine attributes in ANSI, UTF8 or UTF-16 encoding.

In case you have to write attributes with different encodings at the same time, you could make use of the command line and an arg file at the same time, passing non-unicode text via command line and UTF-8 in the arg file.

You can find more information about ExifTool and Unicode here: http://www.christian-etter.de/?p=33.

Archive

[Originally posted by exiftool on 2009-08-20 12:45:48-07]

Thanks for the response Christian,

There now is a new alternative for entering special characters:

In a recent update (version 7.87, released 6 days ago), the -E
option was enhanced to also apply when writing values.  So with this
option special characters can now be entered as HTML character
entities.  For example, "ü",  "ü" and "&#xfc"
all represent the Unicode codepoint 0x00fc (ΓΌ).

- Phil

Archive

[Originally posted by ce on 2009-08-21 09:35:18-07]

As always, Phil is one step ahead ;-)

A very useful feature for command line hackers. For those who would want to write some code to escape special characters, I suppose it is safest to escape all characters except a-z, A-Z and 0-9?

Chris

Archive

[Originally posted by exiftool on 2009-08-21 11:04:32-07]

You don't need to escape that much.  It is only necessary to escape
"&", and any character greater than .  However, it
may be useful to also escape control characters such as newlines
and maybe quotes too if they are difficult for you to produce on the
command line.

- Phil