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 625573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:19:27+00:00 2026-05-13T19:19:27+00:00

I have a string ë́aúlt that I want to get the length of a

  • 0

I have a string ë́aúlt that I want to get the length of a manipulate based on character positions and so on. The problem is that the first ë́ is being counted twice, or I guess ë is in position 0 and ´ is in position 1.

Is there any possible way in Python to have a character like ë́ be represented as 1?

I’m using UTF-8 encoding for the actual code and web page it is being outputted to.

edit: Just some background on why I need to do this. I am working on a project that translates English to Seneca (a form of Native American language) and ë́ shows up quite a bit. Some rewrite rules for certain words require knowledge of letter position (itself and surrounding letters) and other characteristics, such as accents and other diacritic markings.

  • 1 1 Answer
  • 4 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-13T19:19:27+00:00Added an answer on May 13, 2026 at 7:19 pm

    UTF-8 is an unicode encoding which uses more than one byte for special characters. If you don’t want the length of the encoded string, simple decode it and use len() on the unicode object (and not the str object!).

    Here are some examples:

    >>> # creates a str literal (with utf-8 encoding, if this was
    >>> # specified on the beginning of the file):
    >>> len('ë́aúlt') 
    9
    >>> # creates a unicode literal (you should generally use this
    >>> # version if you are dealing with special characters):
    >>> len(u'ë́aúlt') 
    6
    >>> # the same str literal (written in an encoded notation):
    >>> len('\xc3\xab\xcc\x81a\xc3\xbalt') 
    9
    >>> # you can convert any str to an unicode object by decoding() it:
    >>> len('\xc3\xab\xcc\x81a\xc3\xbalt'.decode('utf-8')) 
    6
    

    Of course, you can also access single characters in an unicode object like you would do in a str object (they are both inheriting from basestring and therefore have the same methods):

    >>> test = u'ë́aúlt'
    >>> print test[0]
    ë
    

    If you develop localized applications, it’s generally a good idea to use only unicode-objects internally, by decoding all inputs you get. After the work is done, you can encode the result again as ‘UTF-8’. If you keep to this principle, you will never see your server crashing because of any internal UnicodeDecodeErrors you might get otherwise 😉

    PS: Please note, that the str and unicode datatype have changed significantly in Python 3. In Python 3 there are only unicode strings and plain byte strings which can’t be mixed anymore. That should help to avoid common pitfalls with unicode handling…

    Regards,
    Christoph

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

Sidebar

Related Questions

I have a string (of undertermined length) that I want to copy a lot
I have a string that I want passed via the linebreaks filter. {% trans
I have a string that I want to have PHP read as a piece
Hi I'm new to regexes. I have a string that I want to match
I have a string s that I want to split up so each part
I have string that displays UTF-8 encoded characters, and I want to convert it
I have a string that looks like this: 9/1/2009. I want to convert it
I have a string that looks like this: <name>-<gender>-<age>.jpg I want to be very
For example, I have this string that could change anytime I only want the
I have a simple question. I have a long std::string that I want to

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.