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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:36:48+00:00 2026-05-13T05:36:48+00:00

I have a set of UTF-8 octets and I need to convert them back

  • 0

I have a set of UTF-8 octets and I need to convert them back to unicode code points. How can I do this in python.

e.g. UTF-8 octet [‘0xc5′,’0x81’] should be converted to 0x141 codepoint.

  • 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-13T05:36:49+00:00Added an answer on May 13, 2026 at 5:36 am

    Python 3.x:

    In Python 3.x, str is the class for Unicode text, and bytes is for containing octets.

    If by “octets” you really mean strings in the form ‘0xc5’ (rather than ‘\xc5’) you can convert to bytes like this:

    >>> bytes(int(x,0) for x in ['0xc5', '0x81'])
    b'\xc5\x81'
    

    You can then convert to str (ie: Unicode) using the str constructor…

    >>> str(b'\xc5\x81', 'utf-8')
    'Ł'
    

    …or by calling .decode('utf-8') on the bytes object:

    >>> b'\xc5\x81'.decode('utf-8')
    'Ł'
    >>> hex(ord('Ł'))
    '0x141'
    

    Pre-3.x:

    Prior to 3.x, the str type was a byte array, and unicode was for Unicode text.

    Again, if by “octets” you really mean strings in the form ‘0xc5’ (rather than ‘\xc5’) you can convert them like this:

    >>> ''.join(chr(int(x,0)) for x in ['0xc5', '0x81'])
    '\xc5\x81'
    

    You can then convert to unicode using the constructor…

    >>> unicode('\xc5\x81', 'utf-8')
    u'\u0141'
    

    …or by calling .decode('utf-8') on the str:

    >>> '\xc5\x81'.decode('utf-8')
    u'\u0141'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have terminal.app set to accept utf-8 and in bash I can type unicode
I have set of xml elements like this: <item code=<HTML_CODE> /> For example: <items>
I have a MySQL table & fields that are all set to UTF-8. The
I have set up WebDAv server on my Debian linux and this is working
In the my application I have set some jars as project dependency. This jars
I have a MySQL table properly set to the UTF-8 character set. I suspect
I have both, django and mysql set to work with UTF-8. My base.html set
We have many xml files and most of them are UTF-16 encoded. When I
on my page I have set the UTF-8 encoding. Then, I send a string
<html> <head> <title>тест</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> I have set the meta tag,

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.