# Binary data in TeX \special [closed]

I want to ask if I can output binary information in \special? If it is possible, how do I put the binary in TeX source? In C/C++, for instance \0 can be used to get the byte 00000000 so what could be the equivalent for TeX?

## closed as too broad by egreg, Mensch, Stefan Pinnow, Schweinebacke, CarLaTeXNov 22 '17 at 7:10

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Can you please tell what such a \special would be useful for? – egreg Feb 6 '16 at 17:58
• To assist DVI rendering (for e.g. outputing point coordinates in binary instead of strings would be much faster to parse and process in application such as extending SyncTeX to DVI) and enhance DVI graphic capability (for e.g. including PNG in DVI file). – An Hoa Feb 6 '16 at 19:12

If you mean, can I type \special followed by something, into the .tex source, file to get binary data into the DVI file, then the answer is no (but see below). This is because in TeX \special is not really special: it's just a primitive command (like \def or \write), and it simply writes out the tokens that are given inside \special{...}, while expanding them and so on (like \edef or \xdef). As it's hard to get arbitrary binary data into a TeX token list, you cannot get that written out to a DVI file. (However, see this answer which points out a way it may be possible (just possible, not easy!) using pdflatex -8bit.)
The relevant sections from the TeX program (see it with texdoc tex), showing that \special uses show_token_list etc.:
Even if you could get binary data written out from the TeX source, would it work? The DVI format itself supports arbitrary binary data inside specials (aka the xxx1 to xxx4 commands). However, there is a convention that the data is text; in fact dvitype gives an error or warning when an xxx command contains non-ASCII data.
Of course this may just be a convention from the time of when DVItype was written (last updated 1995), and I haven't examined the DVI specials produced by various packages (or what XeTeX does in its .xdv format). So it is possible that you can have binary data there and get away with it — at least in some DVI drivers, as interpreting the special is entirely up to the DVI driver. But if you are writing your own DVI driver (which is assumed if you're putting unusual specials there), then you might as well instead write the binary data in base64 or some such ASCII-only encoding, and then have the driver decode it into arbitrary data.