Lucas Vieira
Lucas Vieira

Reputation: 181

Python script to parse/convert latex string into utf-8?

I result being retrieved from the db, on this form:

(86, 'B{\\u{a}}beanu', 'Alexandru-Ionut') 
(101, "Dosil Su{\\'a}rez", 'Alvaro') 
(119, 'Massafferri', "Andr{\\'e}") 
(161, 'M{\\"u}ller', 'Anke-Susanne') 

I'd like to decode this characters from latex to unicode, e.g. utf8 (it will be shown on a webpage). But I can't install modules on the server, e.g. latexCodec.

I coudn`t find scripts that worked for me on web, not even this on stackoverflow. Are there any script for work this out?

Thanks you in advance.

Upvotes: 2

Views: 1485

Answers (1)

lvc
lvc

Reputation: 35089

Depending on how your server is set up, you might be able to install a user copy of latexcodec - for example, by using pip install --user or by extracting the tarball into the appropriate pythonx.y folder in ~/.local/lib. If even that isn't an option, you can in the worst case still keep a static copy of it in your project directory. None of these methods will be handled by your , but that doesn't seem likely to be a big problem here - the latexcodec git respository hasn't received any update in nearly a year.

Note that using latexcodec will parse the latex into unicode, not utf-8 encoded bytes - but this is almost certainly what you actually want, and if it really isn't, you can re-encode to utf8 from there.

Upvotes: 3

Related Questions