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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:22:31+00:00 2026-05-17T02:22:31+00:00

Having an UTF-8 string like this: mystring = işğüı is it possible to get

  • 0

Having an UTF-8 string like this:

mystring = "işğüı"

is it possible to get its (in memory) size in Bytes with Python (2.5)?

  • 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-17T02:22:31+00:00Added an answer on May 17, 2026 at 2:22 am

    Assuming you mean the number of UTF-8 bytes (and not the extra bytes that Python requires to store the object), it’s the same as for the length of any other string. A string literal in Python 2.x is a string of encoded bytes, not Unicode characters.

    Byte strings:

    >>> mystring = "işğüı"
    >>> print "length of {0} is {1}".format(repr(mystring), len(mystring))
    length of 'i\xc5\x9f\xc4\x9f\xc3\xbc\xc4\xb1' is 9
    

    Unicode strings:

    >>> myunicode = u"işğüı"
    >>> print "length of {0} is {1}".format(repr(myunicode), len(myunicode))
    length of u'i\u015f\u011f\xfc\u0131' is 5
    

    It’s good practice to maintain all of your strings in Unicode, and only encode when communicating with the outside world. In this case, you could use len(myunicode.encode('utf-8')) to find the size it would be after encoding.

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

Sidebar

Related Questions

Having an utf-8 encoded string like this: bar = hello 。◕‿‿◕。 and a bytes
I am having issues with trying to convert an UTF-8 string to unicode. I
The problem I am having at this point in time (being new to Python)
I have an XML/Soap file that looks like this: <?xml version=1.0 encoding=utf-8?> <soap:Envelope xmlns:soap=http://www.w3.org/2003/05/soap-envelope
I would like to print a string to the screen regardless of its encoding
I have a struct like this: typedef struct string { unsigned long length; unsigned
I java code, I am having a string name = örebro; // its a
I am having utf-8 encoded file containing arabic text and I have to search
I'm currently having non-utf-8 DB but I need to produce XMLType variable with utf-8
I'm using Amazon's RDS, and I'm having difficulty reading utf data from the DB.

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.