[XeTeX] Problem with XeTeXdefaultencoding

Jonathan Kew jonathan at jfkew.plus.com
Mon Aug 4 15:34:54 CEST 2008


On 4 Aug 2008, at 1:39 PM, SUN Wenchang wrote:

>
>
> Dear All,
>
> For some reasons, I need to change the default inputencoding. After  
> the default encoding is changed back to utf-8,
> it can not ignore the UTF-8 leading bytes BOM in a subsequent call  
> to \input{file}.
>
> Attached is an example.
> Note that main-a.tex is a copy of main.tex except removing the line
>   \XeTeXdefaultencoding 'UTF-8'
>

Use \XeTeXdefaultencoding "auto" to restore the default behavior.

XeTeX only "sniffs" the first bytes of the file to determine the  
encoding (and skips an initial BOM, if found) when it is using the  
default "auto" encoding mode. If you explicitly set an encoding --  
including UTF-8 or a UTF-16 form -- it will simply read the entire  
file using that encoding.

If you want to explicitly set the encoding to UTF-8, yet still ignore  
the BOM, you could do this with \catcode"FEFF=9. Or if you think it  
might occur (functioning as ZWNBSP) elsewhere in the text, something  
like

   \catcode"FEFF=\active \def^^^^feff{\ifhmode\kern0pt\fi}

might be useful.

JK




More information about the XeTeX mailing list