# How To Solve The Error: UnicodeDecodeError: ‘utf-8’ Codec Can’t Decode Byte 0x92 In Position In Python

## How does the UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x92 in position In Python happen?

The error occurs when you assign the wrong encoding while you are decoding the bytes object.

byte = 'LearnShareIT ’ crvt4722'.encode('cp1252')
str = byte.decode('utf-8') # The Error will occur here
print(str)

Output

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 13: invalid start byte.

## How to solve this error?

These are some solutions that can help you solve the error. You have to set the same encoding which is used to encode the string while you are decoding the bytes object. You can also ignore the error to fix the problem. Another solution is using the encoding =”ISO-8859-1”.

### Set the same encoding

You have to set the same encoding which is used to encode the string while you are decoding the bytes object.

byte = 'LearnShareIT ’ crvt4722'.encode('cp1252')
str = byte.decode('cp1252')
print(str)

Output

LearnShareIT ’ crvt4722

### Ignore the error

If the error occurs, you ignore the characters that can not be decoded by the error keyword.

with open(file_path,encoding= 'utf-8', errors= 'ignore') as f:
print(content)

### Use the encoding = “ISO-8859-1”

You can use the encoding ISO-8859-1 to solve the error.

with open(file_path,encoding= 'ISO-8859-1') as f:
print(content)