TeX::Encode(3pm)

πŸ“¦
version 2.010 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– TeX::Encode πŸ’–

okay bestie, welcome to TeX::Encode β€” a little Perl module (a 3pm man page, if we're being precise) from the User Contributed Perl Documentation crew. Its whole thing? Encode/decode Perl utf-8 strings into TeX. Let's get into it. πŸŽ€


✨ NAME ✨

TeX::Encode β€” Encode/decode Perl utf-8 strings into TeX. That's it, that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

use TeX::Encode;
use Encode;

$tex = encode('latex', "This will encode an e-acute (".chr(0xe9).") as \'e");
$str = decode('latex', $tex); # Will decode the \'e too!

like… you encode, you decode, you go about your day. iconic. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So this module gives you encoding to LaTeX escapes from utf8, using mapping tables. And here's the tea: it only covers a subset of the Unicode character table, so bestie, undef warnings WILL occur for non-mapped chars. Not a bug, just a boundary. 😭

This module is intentionally vague about what it will handle β€” peep the Caveats below if you wanna know more. 🫢

Decoding? Mileage will vary, ngl. Because TeX is in essence a programming language, and this module does not implement TeX. So like… manage your expectations, queen. πŸ’€

Not me using this module to encode author names in BibTeX and to do a rough job at presenting LaTeX abstracts in HTML. It's giving "good enough." Using decode, instead of seeing $\sqrt{\Omega^2\zeta_n}$ you get something that looks like the formula. Which is lowkey the dream, fr fr. 🧚

The next logical step for this module is to integrate some level of TeX grammar to improve the decoding β€” in particular to handle fractions and font changes (which should probably be dropped). Main character roadmap energy, honestly. πŸ‘‘


πŸ’… METHODS πŸ’…

  • TeX::Encode::encode STRING [, CHECK] β€” Encodes a utf8 string into TeX. CHECK isn't implemented. (yes, it's literally just there in the signature. it does nothing. we love a placeholder. πŸ™ˆ)
  • TeX::Encode::decode STRING [, CHECK] β€” Decodes a TeX string into utf8. CHECK isn't implemented either, same situation, same energy. 😭
  • TeX::Encode::perlio_ok β€” Returns 0. PerlIO isn't implemented. Short answer, no notes. πŸ’€

πŸŽ€ CAVEATS πŸŽ€

bestie, read this part. it's the "know before you go" section. πŸ’–

Proper Encode checking is not implemented.

LaTeX comments (% ...) are ignored, because chopping a lot of text may not be what you actually want. (they're being polite about it but the reasoning is sound, ngl.) 🌸

🌈 encode()

Converts non-ASCII Unicode characters to their equivalent TeX symbols. Heads up: unTeXable characters will result in undef warnings. you've been warned, bestie. ⭐

🌈 decode()

Attempts to convert TeX symbols (e.g. \ae) to Unicode characters. As an experimental feature, this also handles Math-mode TeX by inserting HTML into the resulting string β€” so you end up with an HTML approximation of the maths. NOT MathML. no cap, HTML. πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

  • Encode::Encoding
  • Pod::LaTeX
  • Encode

go read those too, iykyk. πŸ“šβœ¨


πŸ‘‘ AUTHOR πŸ‘‘

  • Timothy D Brody, <tdb01r@ecs.soton.ac.uk>
  • Ahmad Fatoum "<athreef@cpan.org>", <http://a3f.at>

legends, both of them. 🫢


Copyright (C) 2005-2007 by Timothy D Brody

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.


and that's the whole page, bestie! πŸ’– this one's from perl v5.36.0, dated 2022-10-13 β€” so when you cite it, cite it cute. mwah, go encode something. πŸ’…πŸŽ€βœ¨

πŸ“¦ where this page comes from