Python Forum
UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin
#1
Hey everyone !

I have a strange problem. I would like to send this line to a waveform generator: 'DATA EMEM,#14?\xfd?\xfd'.

I get this error : UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordinal not in range(128)

I found a lot of topics on the Internet to solve this problem, and the solution seems to be to encode the string with .encode('utf-8').

The problem is that encoding with this function puts a b'[my_code]' around my code, and when I send it to my device, it obviously doesn't understand it because it doesn't expect a binary table but a string ... So I try to convert it to a string but I come back to the first problem ....

How can I keep the encoding while deleting this b' ' around my string ?

I hope my problem is quite clear and that someone can help me !
Thanks a lot ! :)
Reply


Messages In This Thread
UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin - by Armandito - Apr-29-2022, 09:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  encode/decode to show correct country letters in a CTk combobox janeik 2 711 Sep-02-2023, 09:46 AM
Last Post: janeik
Question UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 562: ord ctrldan 23 4,808 Apr-24-2023, 03:40 PM
Last Post: ctrldan
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid cont Melcu54 3 4,931 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 1,023 Nov-16-2022, 11:41 AM
Last Post: Winfried
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 18,871 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  UnicodeEncodeError - Dealing with Japanese Characters fioranosnake 2 2,444 Jul-07-2022, 08:43 PM
Last Post: fioranosnake
  UnicodeEncodeError caused by print when program runs from Popen SheeppOSU 5 2,911 Jan-13-2022, 08:11 AM
Last Post: SheeppOSU
  [UnicodeEncodeError from smtplib] yoohooos 0 3,383 Sep-25-2021, 04:27 AM
Last Post: yoohooos
  ASCII-Codec in Python3 [SOLVED] AlphaInc 4 6,121 Jul-07-2021, 07:05 PM
Last Post: AlphaInc
  [solved] unexpected character after line continuation character paul18fr 4 3,394 Jun-22-2021, 03:22 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020