jamesremuscat / pcars

Python client for Project CARS UDP data stream.
15 stars 16 forks source link

pcars.py, lines 27 and 30 ... #11

Closed ghost closed 6 years ago

ghost commented 6 years ago

... go

convertedValue = unicode(stringAsBytes, encoding='utf-8', errors='ignore')

and

convertedValue = str(stringAsBytes, encoding='utf-8', errors='surrogateescape')

The encoding should be iso_8859_1 instead of utf-8, otherwise German umlauts, like in Nürburgring, are not displayed properly.

jamesremuscat commented 6 years ago

Thanks - any chance you could pull all these changes together in a PR for me?

ghost commented 6 years ago

Hmm :-).

I think rather not. I am not familiar with github in particular, nor with git in general. I wouldn't know in the first place, whether I need to clone or fork something :-).

However, the 2nd and 3rd reported bugs are trivial to fix, and for the 1st I can spare you some testing, if you consider my coding:

def _convertString(self, stringAsBytes):                                                                          

  if len(s_00) == 0: # if first byte is already 0x00                                                              
    return ''                                                                                                     

  pos = stringAsBytes.index(bytes([0x00]))                   # assumes, that pos is not -1                        
  result = str(stringAsBytes[:pos], 'iso_8859_1', 'replace') # iso_8859_1 due to umlaut (latin-1 should also work)

  return result                                                                                                   

Of course, this is just Python 3 code, while you have both Python 2 and 3 covered.

Sorry for not being of more help :-).