Skip to content
Discussion options

You must be logged in to vote

ScanResult.name() will interpret (decode) the name as UTF-8 string using str(name,'utf8'). The trailing nulls will remain as null characters at the end of the string. To be sure to have the "ascii only" characters, replace the nulls by "":

>>> advertised_name=b'1SC100\x00\x00\x00\x00\x00\x00\x00\x00'
>>> name_as_string=str(advertised_name,"utf-8")
>>> name_as_string
'1SC100\x00\x00\x00\x00\x00\x00\x00\x00'
>>> trimmed_name=name_as_string.replace("\x00","")
>>> trimmed_name
'1SC100'

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@brianreinhold
Comment options

@bixb922
Comment options

Answer selected by brianreinhold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants