First find the encoding of the string and then decode it... to do this you will need to make a byte string by adding the letter 'b' to the front of the original string.

Try this:

import chardet

s = "Aur\xc3\xa9lien"
bs = b"Aur\xc3\xa9lien"

encoding = chardet.detect(bs)["encoding"]

str = s.encode(encoding).decode("utf-8")

print(str)

If you are reading the text from a file you can detect the encoding using the magic lib, see here: https://stackoverflow.com/a/16203777/1544937

Answer from jgphilpott on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-strings-decode-method
Python Strings decode() method - GeeksforGeeks
May 11, 2026 - decode() method is used to convert encoded text back into its original string format. It works as the opposite of encode() method, which converts a string into a specific encoding format.
🌐
Tutorialspoint
tutorialspoint.com › python › string_decode.htm
Python String decode() Method
The python string decode() method decodes the string using the codec registered for its encoding. The encoded string can be decoded and the original string can be obtained with the help of this function.
🌐
Mimo
mimo.org › glossary › python › string-decode
Python string decode(): Syntax, Usage, and Examples
The decode() method in Python is used to convert byte data into a Unicode string. In Python 3, strings are Unicode by default, so decode() applies specifically to bytes objects.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-string-encode-decode
Python String Encode and Decode: Complete Guide | DigitalOcean
Master Python string encode() and decode() methods. Learn UTF-8, ASCII, Unicode handling, error handling modes, and practical encoding/decoding examples.
🌐
AskPython
askpython.com › python › string › python-encode-and-decode-functions
Python encode() and decode() Functions - AskPython
February 16, 2023 - The second one is correct since the encoding and decoding formats are the same. a = 'This is a bit möre cömplex sentence.' print('Original string:', a) # Encoding in UTF-8 encoded_bytes = a.encode('utf-8', 'replace') # Trying to decode via ASCII, which is incorrect decoded_incorrect = encoded_bytes.decode('ascii', 'replace') decoded_correct = encoded_bytes.decode('utf-8', 'replace') print('Incorrectly Decoded string:', decoded_incorrect) print('Correctly Decoded string:', decoded_correct)
🌐
Python documentation
docs.python.org › 3 › howto › unicode.html
Unicode HOWTO — Python 3.14.7 documentation
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte >>> b'\x80abc'.decode("utf-8", "replace") '\ufffdabc' >>> b'\x80abc'.decode("utf-8", "backslashreplace") '\\x80abc' >>> b'\x80abc'.decode("utf-8", "ignore") 'abc' Encodings are specified as strings containing the encoding’s name.
🌐
DataScience Made Simple
datasciencemadesimple.com › home › encode and decode string in python – encode() & decode() function
Encode and Decode string in python - Encode() & Decode() function - DataScience Made Simple
February 4, 2023 - # example of decoding the string in python string_decoded=string_encoded.decode('base64','strict'); print "Decoded string is :"+ string_decoded;
Find elsewhere
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › str › decode.html
decode — Python Reference (The Right Way) 0.1 documentation
Defaults to the default string encoding. See codecs module for a full list. ... Optional. errors may be given to set a different error handling scheme. ... Raise ValueError (or a subclass); this is the default. ... Ignore the character and continue with the next. ... Other possible values are any other name registered via codecs.register_error(), see section Codec Base Classes. ... >>> 'źdźbło'.decode('windows-1250') # polish word meaning a blade of grass u'\u0139\u015fd\u0139\u015fb\u0139\u201ao' >>> 'źdźbło'.decode('ascii', 'strict') Traceback (most recent call last): File "<interactive input>", line 1, in <module> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 0: ordinal not in range(128) >>> 'źdźbło'.decode('ascii', 'ignore') u'dbo' >>> 'źdźbło'.decode('ascii', 'replace') u'\ufffd\ufffdd\ufffd\ufffdb\ufffd\ufffdo'
🌐
Medium
medium.com › @vanitaaiofficial › decode-string-in-python-step-by-step-leetcode75-solution-5e1b62ce9f49
Decode String in Python — Step-by-Step LeetCode75 Solution | by Vanita AI | Medium
October 5, 2025 - k[encoded_string], where encoded_string is repeated exactly k times. ... Nested encodings like "3[a2[c]]" are possible. Your task: Decode the string and return the final decoded result.
🌐
Linux Hint
linuxhint.com › python-string-decode-method
Linux Hint – Linux Hint
April 10, 2023 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Python Module of the Week
pymotw.com › 2 › codecs
codecs – String encoding and decoding - Python Module of the Week
$ python codecs_encodings.py Raw : u'pi: \u03c0' UTF-8 : 70 69 3a 20 cf 80 UTF-16: fffe 7000 6900 3a00 2000 c003 · Given a sequence of encoded bytes as a str instance, the decode() method translates them to code points and returns the sequence as a unicode instance.
🌐
Educative
educative.io › answers › how-to-decode-an-encoded-string-in-python
How to decode an encoded string in Python
Once we know the encoding format, we can use Python's built-in module codecs to decode the string.
🌐
Python Central
pythoncentral.io › series › python-encoding-decoding-strings
Encoding and Decoding Python Strings Series | Python Central
Prerequisites Knowledge of the following is required: Python 3 Basic HTML Urllib2 (not mandatory but recommended) Basic OOP concepts Python data structures – Lists, Tuples Why parse HTML? Python is one of the languages that is extensively used to scrape data from web pages.
🌐
Scaler
scaler.com › home › topics › python decode() function
Python Decode() Function - Scaler Topics
September 4, 2024 - The python decode method is used to decode the encoded form of a string. The python decode uses the codecs that are registered for encoding. By default, the python decode uses the UTF-8 encoding value.
🌐
Medium
medium.com › @vivekmcm1 › understanding-pythons-encode-and-decode-with-real-world-examples-5d2080d66f01
Understanding Python’s encode() and decode() with Real-World Examples | by Vivek | Medium
August 30, 2025 - ... text = "Hello World" byte_text ... because ASCII cannot represent it. ... Decoding is the reverse process: converting bytes back into a string....
🌐
Python
docs.python.org › 3 › library › codecs.html
codecs — Codec registry and base classes
Given a str string of up to 256 characters representing a decoding table, returns either a compact internal mapping object EncodingMap or a dictionary mapping character ordinals to byte values. Raises a TypeError on invalid input. The full details for each codec can also be looked up directly: ... Looks up the codec info in the Python codec registry and returns a CodecInfo object as defined below.
🌐
MindStick
mindstick.com › interview › 34374 › encode-and-decode-string-function-in-python
encode and decode string function in python? – MindStick
September 17, 2025 - Converts bytes back to string. decoded = encoded.decode("utf-8") # bytes → str print(decoded) # "Hello नमस्ते" import base64 text = "Python Encoding" # Encode string to Base64 encoded = base64.b64encode(text.encode("utf-8")) print(encoded) # b'UHl0aG9uIEVuY29kaW5n' # Decode Base64 back to string decoded = base64.b64decode(encoded).decode("utf-8") print(decoded) # Python Encoding
🌐
Python.org
discuss.python.org › python help
How can in decode this string? - Python Help - Discussions on Python.org
May 2, 2020 - how can I get the file name from this type of encode string? 4EK4hB_X0ZfUOEi7ltY4j5fM94TlkLirbywKzVnK_F-8VS5Y8Q7P9Xr9a8cgA9yBjmRnz92K-V4keCWMLA4cywjF1oPhKecRuOkceNU0R1WqOoZiludfbXOcvsHINyCSqojvfl8abgbDooyQXaMsuMStpti0nKJ5HGmgy4rzpsn1AcJyg9dfQp1nYToVZwEGt0Ttc62zTSSp-l9kCGVT1jiMqZahSpr_rkknPcQitvVWSK8Qv-Akju36BmukOx-91ZheKRu0V3b6EbAe9-d11GRWe4-YqPvX3q9WGvhdhWLIBKiZ8CNkFWLml8WPNS9-SaW5vJDrDm8CWF2kvXOqD25bVLieZW5sGYVexv5urx2AWqhx9C4Bb5FP-BoOaIMNmaTUUifWbqiyMUSeRc7vDRas6ITjwRHbGtcVq4hpSQqJrknja_XMCL...
🌐
Python Central
pythoncentral.io › encoding-and-decoding-strings-in-python-3-x
Encoding and Decoding Strings (in Python 3.x) | Python Central
December 29, 2021 - Encoding and decoding strings in Python 2.x was somewhat of a chore, as you might have read in another article. Thankfully, turning 8-bit strings into unicode strings and vice-versa, and all the methods in between the two is forgotten in Python 3.x.