What would be the best way or a simple and good way to encode string data in python for later reading in php?
Failed examples:
1: In Python:
>>> encoded = u'test ö'.encode('utf-8')
'text \xc3\xb6'
In PHP:
>>> $decoded = utf8_decode('test \xc3\xb6');
test \xc3\xb6
???
2: In Python:
>>> encoded = u'test ö'.encode('latin-1')
'test \xf6'
In PHP:
$decoded = ???;
You have to use double quotes to get backslash escape sequences parsed in PHP.
And using UTF8 is certainly one of the most interoperable ways to pass string data between programming languages / systems / etc.