<div dir="ltr">Hi Roger,<div><br></div><div>> The problem lies with the behaviour of Java on Windows.</div><div><br></div><div>Nice detective work. :-)</div><div><br></div><div>I am curious: do you know whether it works with:</div><div><br></div><div>* The PowerShell console</div><div>* A Cygwin terminal</div><div>* An MSYS (e.g., Git Bash) terminal</div><div><br></div><div>?</div><div><br></div><div>Regards,</div><div>Curtis</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><span style="font-size:12.8px">--</span></div><div><span style="font-size:12.8px">Curtis Rueden</span><br></div><div><span style="font-size:12.8px">LOCI software architect - <a href="https://loci.wisc.edu/software" target="_blank">https://loci.wisc.edu/software</a></span></div><div>ImageJ2 lead, Fiji maintainer - <span style="font-size:12.8px"><a href="https://imagej.net/User:Rueden" target="_blank">https://imagej.net/User:Rueden</a></span></div><div><br></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Sep 6, 2017 at 7:57 AM, Roger Leigh <span dir="ltr"><<a href="mailto:rleigh@dundee.ac.uk" target="_blank">rleigh@dundee.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 01/09/17 20:30, Christoph Gohlke wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
one issue is that the tiffcomment utility outputs XML that is not well<br>
formed. OME-XML should be UTF-8 encoded, but tiffcomment apparently<br>
encodes with latin1, iso-8859-1, or similar (Bioformats 5.6.0 on Windows<br>
10).<br>
Try re-encoding the XML file (e.g. in Python3 Q&D):<br>
<br>
xml = open('comment.xml', 'rb').read()<br>
xml = xml.decode('iso-8859-1').encod<wbr>e('utf8')<br>
open('comment.xml', 'wb').write(xml)<br>
<br>
Another issue could be that the XML in the ome.tiff file is not encoded<br>
correctly. Open the ome.tiff file with a HEX editor. The lower case Mu<br>
letter should be stored in two bytes (C2 B5), not just one byte (B5).<br>
</blockquote>
<br></span>
The problem lies with the behaviour of Java on Windows.<br>
<br>
tiffcomment uses System.out.println() to print the comment to standard<br>
output, and this uses the default encoding. On Windows, this is likely<br>
to be an old 8-bit codepage such as CP1252, which will result in the<br>
output being recoded from UTF-8 to whatever codepage is in use. Please<br>
see<br>
<a href="https://stackoverflow.com/questions/24803733/default-character-encoding-for-java-console-output" rel="noreferrer" target="_blank">https://stackoverflow.com/ques<wbr>tions/24803733/default-charact<wbr>er-encoding-for-java-console-<wbr>output</a><br>
for further details.<br>
<br>
You could try to force the use of UTF-8 by making this change to the<br>
bf.bat script which is part of bftools:<br>
<br>
<br>
diff --git a/tools/bf.bat b/tools/bf.bat<br>
index 0c56b79388..6f3146e956 100644<br>
--- a/tools/bf.bat<br>
+++ b/tools/bf.bat<br>
@@ -22,6 +22,14 @@ if "%BF_MAX_MEM%" == "" (<br>
)<br>
set BF_FLAGS=%BF_FLAGS% -Xmx%BF_MAX_MEM%<br>
<br>
+rem Set the file encoding<br>
+if "%BF_ENCODING%" == "" (<br>
+ rem Set UTF-8 by default<br>
+ set BF_ENCODING=UTF-8<br>
+)<br>
+set "BF_FLAGS=%BF_FLAGS% -Dfile.encoding=%BF_ENCODING%"<br>
+<br>
+<br>
rem Skip the update check if the NO_UPDATE_CHECK flag is set.<br>
if not "%NO_UPDATE_CHECK%" == "" (<br>
set BF_FLAGS=%BF_FLAGS% -Dbioformats_can_do_upgrade_ch<wbr>eck=false<br>
<br>
It's not something which we can enable by default, because this is not a<br>
setting which is supposed to be used publicly, but it may help in this case.<br>
<br>
An alternative solution would be to use a Unix platform such as Linux,<br>
FreeBSD or MacOS X with a UTF-8 locale, where the output will always be<br>
correctly encoded as UTF-8.<br>
<br>
As a better long term solution, we could reopen System.out to use a<br>
UTF-8 encoding, or to use raw bytes and transfer everything verbatim.<br>
<br>
<br>
Kind regards,<br>
Roger<br>
<br>
--<br>
Dr Roger Leigh -- Open Microscopy Environment<br>
Wellcome Trust Centre for Gene Regulation and Expression,<br>
College of Life Sciences, University of Dundee, Dow Street,<br>
Dundee DD1 5EH Scotland UK Tel: (01382) 386364<span class="im HOEnZb"><br>
<br>
The University of Dundee is a registered Scottish Charity, No: SC015096<br></span><div class="HOEnZb"><div class="h5">
______________________________<wbr>_________________<br>
ome-users mailing list<br>
<a href="mailto:ome-users@lists.openmicroscopy.org.uk" target="_blank">ome-users@lists.openmicroscopy<wbr>.org.uk</a><br>
<a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users" rel="noreferrer" target="_blank">http://lists.openmicroscopy.or<wbr>g.uk/mailman/listinfo/ome-user<wbr>s</a><br>
</div></div></blockquote></div><br></div></div>