I'm facing issues to decode the following hex string in python 3.4:
b'"\x00\x08\x00\x83\x80\x00\x00\x00\x86\x11\x1dBA\x8c\xdb\xc0\\p\xfe#NR09G06654\x00\x00\x00'
I'm trying with a simple:
data = b'"\x00\x08\x00\x83\x80\x00\x00\x00\x86\x11\x1dBA\x8c\xdb\xc0\\p\xfe#NR09G06654\x00\x00\x00'
print(data.decode('ascii'))
But I am getting the following error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 4: ordinal not in range(128)
I have also tried to change to UTF-8
print(data.decode('utf-8'))
But with no success as the error is:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
I have no clue what the problem could be.
There are many communication protocols for GPS devices. A lot of devices use NMEA0183, but that is a plain text protocol and this is clearly not plain text.
If you're not running ms-windows, you should check if your GPS is supported by gpsd. It translates the signals from the GPS into something understandable. It has Python bindings available.
Related
i have a function returns objects as memoryView as follows:
data:[(<memory at 0x000001C665563E80>,)]
data[0]:(<memory at 0x000001C665563E80>,)
data[0][0]:<memory at 0x000001C665563E80>
as an attempt to see the data contained in the memoryView, i altered the encoding to be iso-8859-1 and used .tobytes but both resulted in an empty string as follwos
iso-8859-1:
tobytes:b''
i also used base64.b64encode(data[0][0]) and the result was base64_data:b''
please let me know how to extract the data contained in a memoryView objects
NOTE:i am using windows operating system
errors received:
UnicodeEncodeError: 'charmap' codec can't encode character '\x93'
UnicodeEncodeError: 'charmap' codec can't encode character '\x89'
attempts to solve this issue:
str(data[0][0],'iso-8859-1')#> caused:UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 1: invalid start byte and UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91
running: `chcp 65001` #>did not solve it
I want to create a program that decodes wifi passwords.
I am not finished yet, but the program should print the names of all wifis. But there is this error and
I don't know how to fix it.
import subprocess
data = subprocess.check_output(["netsh", "wlan", "show", "profiles"]).decode("utf-8").split("\n")
wifis = [line.split(":")(1)[1:-1] for line in data if "All User Profile" in line]
print (data)
Error:
data = subprocess.check_output(["netsh", "wlan", "show", "profiles"]).decode("utf-8").split()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position 76: invalid start byte
netsh is a hint that you are using a Windows system. The console applications often use cp850 encoding for West European languages. So you could try :
data = subprocess.check_output(["netsh", "wlan", "show", "profiles"]).decode("cp850").split("\n")
Or to be safe you can use an encoding able to accept any input byte like latin1 but it seldom returns the expected characters on Windows. But NEVER use utf-8 when the input is not utf-8 encoded.
Does anybody know how to decode the NAV_PVT message in python?
I tried the UTF-8 but it I get this error message:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 0: invalid start byte
I can't find the right decode format.
You should read the file as binary, because it is binary. UBlox has a nice documentation on various formats/protocols. Check them
E.g. https://www.u-blox.com/sites/default/files/products/documents/u-blox8-M8_ReceiverDescrProtSpec_%28UBX-13003221%29.pdf page 332. Is this what you are looking for?
Or if you were using some libraries, you should check such documentation. But I assume or you mixed up the binary with ascii version, or you are just using the binary protocol.
So, I am facing a huge issue. I am trying to read a csv file which has '|' as delimiters. If I use utf-8 or utf-sig-8 as encoders then I get the following error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 0: invalid start byte
but I use the unicode_escape encoding then I get this error:
UnicodeDecodeError: 'unicodeescape' codec can't decode byte 0x5c in position 13: \ at end of string
Is it an issue with the dataset?
it worked after I 'Saved with Encoding - utf-8' in Sublime Text Editor. I think the data had some issues.
I am trying to build up a network using Networkx library in python. Some of the node names are url links.
For example, one of the urls are 'http://www.everydayhealth.com/health-recipe/summer-vegetable-cr+\x8cpes.aspx?pos=3'
I am trying to save the network in gml format and it gives me the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 111: ordinal not in range(128)
Based on the links I read, I know that the url is a 'string' and not a 'unicode'. I checked it using type(url). But because it gives me the above error it means it does not contain all ASCII characters. So, I tried the following:
u1=url.decode('ascii')
It gives me the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0x8c in position 64: ordinal not in range(128)
How should I go about it?
My main purpose is to save this network in a gml format. Any help will be appreciated.
Thank You
have you tried to change encoding?
this may help you https://docs.python.org/2/howto/unicode.html