0

I would like to include the content of a binary file within filecontents. Is there any way to do so?

My MWE is as follows:

\documentclass{article}
\begin{filecontents}{file.txt}
    CPYA 4,3268 195 W64 #
    s   
     ÷˙÷˙‰    Y           Z*oG8#@      á~  a>  ‹-  ‚  î9  ˘o  É}                                          x
“   
  @˙ P   Ä        ÷ !Q        
         đ?      đ?        
0                        Book1_A                  ÎM                              
@  

\end{filecontents}

TobiR
  • 584
  • 2
    Tex can not write binary files done byteswill not be written by default and bytes that look like line endings Willbe normalised – David Carlisle May 24 '21 at 19:05
  • 1
    Related: https://tex.stackexchange.com/questions/408511/use-filecontents-environment-to-write-a-binary-file – Steven B. Segletes May 24 '21 at 19:05
  • @DavidCarlisle In this case, my goal would be to check whether the content of a file can be put within filecontents (without errors) or not. Is there any criterion to test this? – TobiR May 24 '21 at 20:15
  • @TobiR you won't get errors just silent corruption. It depends on the settings of the user, eg it is a user commandline option or texmf.cnf setting whether to write control characters (bytes 0-31) as themselves or as ^^G notation. ends of lines are trickier as you can not tell from within tex what line embeding the file had originally so if there happened to have been a byte 13 or byte 10 in the binary stream you will see them as end of line with no way to distinguish them. – David Carlisle May 24 '21 at 20:24
  • @DavidCarlisle, Let me be more specific. I have a multi-file LaTeX project under Overleaf, which can be smoothly compiled and "run". I would download this directory and create filecontents from the auxiliary files used actively within the document to build the output PDF file. I have the list of ALL files within the project, but I would like to exclude the "non-text" files (like figures and other PDFs present in the directory) not needed to creat the output PDF. Do you have any idea how to do this to avoid creating incorrect filecontents? The .dep file (snapshot) does not help. :( – TobiR May 24 '21 at 20:37

0 Answers0