Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3668260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:06:05+00:00 2026-05-19T02:06:05+00:00

Given a Unicode string, I want to replace non-ASCII characters by LaTeX code producing

  • 0

Given a Unicode string, I want to replace non-ASCII characters by LaTeX code producing them (for example, having é become \'e, and œ become \oe). I’m incorporating this into a Python code. This should rely on a translation table, and I have come up with the following code, which is simple and seems to work nicely:

accents = [
    [ u"à", "\\`a"],
    [ u"é", "\\'e"]
  ]
translation_table = dict([(ord(k), unicode(v)) for k, v in accents])
print u"été à l'eau".translate(translation_table)

But, writing a rather complete translation table will take me a long time, and Google didn’t help much. Does someone have such a thing ready, or know where to find one?

PS: I’m new to Python, so I welcome comments on the code above, of course.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:06:05+00:00Added an answer on May 19, 2026 at 2:06 am

    Download the Unicode Character Database (about 1MB). you can find a relational table for equivalent character combination for example é = \u00E9 is e+ ́ that is equivalent to \u0065+\u0301 (LATIN SMALL LETTER E+COMBINING ACUTE ACCENT). you can write simple codes for converting all combinational characters of all scripts or just them you want (you can control by script field in database).

    Then replace the combinations with LaTeX code. for example use regular expression \w\u0065 to replace diactrics :\'<the_letter>. (I’m not sure about syntax. It depends on your programming language and regular expression engine.)

    EDIT:
    If you are using python, you have already the database and an implementation of a handler to use it. just like mentioned in below comment, import unicodedata.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to calculate SHA1 hash of a unicode string using T-SQL. The below
Given a string in the following format (the Posterous API returns posts in this
When parsing a PDF, given a string (popped from the Tj or TJ operator
I'm working on Windows with Python 2.6.1. I have a Unicode UTF-16 text file
I am working on one application in which i need to know Unicode of
According to the official Firebird documentation , columns containing Unicode strings (what SQL Server
I'm writing a utility (which happens to be in python) which is generating output
First and foremost: JSON and XML are not an option in this specific case,
I am trying to read from Python the WM_COPYDATA message some applications (I'm trying
Im doing some changes in Linux locale files /usr/share/i18n/locales (like pt_BR), to change the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.