UnicodeDecodeError when pasting Emojis and Alt codes

I built this simple program to count how many characters are in an input take_String.

import os 

def Intro():
  print("This will tell you how many characters are in a string.")
  print("Type !QUIT! to exit. or !CLEAR! to clear the screen.")

Intro()

while True:
  print()
  take_String = input("Enter a string.\n")
  if take_String == "!QUIT!":
    exit()
  elif take_String == "!CLEAR!":
    os.system("clear")
    Intro()
  else:
    print("Your string is",len(take_String),"characters long.")

I tried entering (alt numpad 255) copying it, deleting what I typed in, and then pasting it back in …

I’ll sometimes get this error:

Traceback (most recent call last):
File “/home/runner/ActiveCriminalScans/main.py”, line 11, in
take_String = input(“Enter a string.\n”)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xc2 in position 0: invalid continuation byte

I tried it with :slight_smile: (alt numpad 258) and other emojis (:disguised_face:) and got this error :

UnicodeDecodeError: ‘utf-8’ codec can’t decode bytes in position 0-1: invalid continuation byte

error

  1. Type in :thought_balloon:
  2. Copy :thought_balloon:
  3. Backspace :thought_balloon:
  4. Paste :thought_balloon: and enter

UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-2: invalid continuation byte

If for step 3 I backspace twice instead :
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 0-1: invalid continuation byte

I don’t know why anyone would do this but just thought I’d mention it.

https://replit.com/@vvithershins/Len-of-input