# [XeTeX] latin-1 encoded characters in commented out parts trigger log warnings

Ross Moore ross.moore at mq.edu.au
Mon Feb 22 02:26:32 CET 2021

Hi Jonathan, and others.

On 22 Feb 2021, at 10:39 am, Jonathan Kew <jfkthame at gmail.com<mailto:jfkthame at gmail.com>> wrote:

On 21/02/2021 22:55, Ross Moore wrote:
The file reading has failed  before any tex accessible processing has happened (see the ebcdic example in the TeXBook)
OK.

Also pdfTeX has no trouble with an xstring example.
It just seems pretty crazy that the comments need to be altered
for that package to be used with XeTeX.

Well.... as long as the Latin-1 accented characters are only in comments, it arguably doesn't "really" matter; xetex logs a warning that it can't interpret them, but if you know that part of the line is going to be ignored anyway, you can ignore the warning.

There’s actually a pretty easy fix, at least for XeLaTeX.
The package contains 2 files only:   xstring.sty  and  xstring.tex .
The .sty is just a 1-liner to load the .tex .

It could be beefed up with:

\RequirePackage{ifxetex}     %   is this still the best package for  \ifxetex   ?
\ifxetex
\XeTeXdefaultencoding "iso-8859-1"
\input{xstring.tex}
\XeTeXdefaultencoding "utf8"
\else
\input{xstring.tex}
\fi

(ignore if straight quotes have become curly ones in my email editor!)

Even nicer would be to beef it up further by:
1. record the current default encoding – is this possible ?
then restore from this.
2. use a grouping while deciding what to do,
expanding the required commands before ending the group.

\showthe\XeTeXdefaultencoding  doesn’t work,
so is there another container that tells what is the default encoding?
Or should we always assume it is UTF-8 and revert to that afterwards?

e.g. something like:

\RequirePackage{ifxetex}
\begingroup
\def\next{\endgroup \input{xstring.tex}}%
\ifxetex
\XeTeXdefaultencoding "iso-8859-1"
\def\next{\endgroup
\input{xstring.tex}%
\XeTeXdefaultencoding "utf8"}%
\fi
\next

(pdfTeX doesn't care because it simply reads the bytes from the file; any interpretation of bytes as one encoding or another is handled at the TeX macro level.)

Right.
Which is why I do my PDF development work in pdfTeX before
testing whether it can be adapted also to XeTeX and/or LuaTeX.

JK

Cheers.

Ross

Dr Ross Moore
Department of Mathematics and Statistics
12 Wally’s Walk, Level 7, Room 734
Macquarie University, NSW 2109, Australia
T: +61 2 9850 8955  |  F: +61 2 9850 8114
M:+61 407 288 255  |  E: ross.moore at mq.edu.au<mailto:ross.moore at mq.edu.au>
http://www.maths.mq.edu.au
[cid:image001.png at 01D030BE.D37A46F0]
CRICOS Provider Number 00002J. Think before you print.
Please consider the environment before printing this email.

This message is intended for the addressee named and may
contain confidential information. If you are not the intended
recipient, please delete it and notify the sender. Views expressed
in this message are those of the individual sender, and are not
necessarily the views of Macquarie University. <http://mq.edu.au/>
<http://mq.edu.au/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/xetex/attachments/20210222/63216495/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 4605 bytes
Desc: image001.png
URL: <https://tug.org/pipermail/xetex/attachments/20210222/63216495/attachment-0001.png>