TeX::E...:BibTeX(3pm)
π NAME π
TeX::Encode::BibTeX β the lil module that encodes and decodes Perl utf-8 strings into BibTeX, no cap β¨ (it's a Perl module, and the man page for it lives in section 3pm, which is giving "3pm, user-contributed Perl documentation" energy π
)
πΈ SYNOPSIS πΈ
use TeX::Encode;
use Encode;
$tex = encode('bibtex', "This will encode an e-acute (".chr(0xe9).") as \'e");
$str = decode('bibtex', $tex); # Will decode the \'e too!
okay bestie look at that second line β you hand it an e-acute made with chr(0xe9) and it comes back out as \'e, and then decode turns that \'e right back into the e-acute. the way that round-trips?? iconic π¦
β¨ DESCRIPTION β¨
So this module does encoding to LaTeX escapes from utf8 using mapping tables. That's it, that's the job π
But β important β it covers only a subset of the Unicode character table. For characters that aren't in the mapping you're gonna get undef warnings. It happens. Don't panic. π
This module is intentionally vague about what it will actually handle β for the receipts, see Caveats below. (Yes, it's secretive. Main character behavior.)
Mileage will vary when decoding (that's converting TeX back to utf8, bestie), because TeX is in essence a programming language, and this module does not implement TeX. So like, temper your expectations, fr fr. π«Ά
The author uses this module to encode author names in BibTeX, and to do a rough job at presenting LaTeX abstracts in HTML. When you use decode, instead of staring at $\sqrt{\Omega^2\zeta_n}$, you get something that actually looks like the formula. Ate. π₯
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). Manifesting that upgrade β¨
π METHODS π
TeX::Encode::BibTeX::encode STRING [, CHECK]β Encodes a utf8 string into TeX.CHECKisn't implemented. (Yeah, it's just vibes in that slot, sorry bestie π)TeX::Encode::BibTeX::encode_url STRINGβ Make a URL safe for inclusion in BibTeX. πTeX::Encode::BibTeX::decode STRING [, CHECK]β Decodes a TeX string into utf8.CHECKisn't implemented either. (Consistent, at least. π)TeX::Encode::perlio_okβ Returns0. PerlIO isn't implemented. Periodt.
π CAVEATS π
Proper Encode checking is not implemented. That's it. That's the caveat. π
LaTeX comments (% ...) are ignored, because chopping out a lot of text may not be what you actually want. Like, respect, honestly. π
π encode() π
Converts non-ASCII Unicode characters to their equivalent TeX symbols. (unTeXable characters will result in undef warnings.) β
π¦ 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. So important to say: NOT MathML. It's giving "approximation" and that's the whole point π
π SEE ALSO π
Encode::EncodingPod::LaTeXEncode
π AUTHOR π
Timothy D Brody, <tdb01r@ecs.soton.ac.uk> π«Ά
π§ COPYRIGHT AND LICENSE π§
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.
okay that's the whole page bestie, go forth and encode responsibly π
mwah π β this was perl v5.36.0, dated 2022-10-13, from the TeX::E...:BibTeX(3pm) corner of the manual, and yes the name is foreshortened like that on purpose, we don't make the rules π
β¨
π¦ where this page comes from
- ubuntu noble: libtex-encode-perl 2.010-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtex-encode-perl 2.010-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtex-encode-perl 2.010-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms