Apr-29-2022, 09:23 AM
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 ! :)
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 ! :)