swoole / phpy

Connecting the Python and PHP ecosystems together
Apache License 2.0
543 stars 44 forks source link

Fix python config #45

Closed Yurunsoft closed 9 months ago

Yurunsoft commented 9 months ago

Fix some encoding problems

python:

import locale;
import sys;

print(locale.getdefaultlocale())
print(locale.getpreferredencoding())
print(sys.getdefaultencoding())
print(sys.getfilesystemencoding())

php:

$locale = PyCore::import('locale');
$sys = PyCore::import('sys');
var_dump((string) $locale->getdefaultlocale());
var_dump((string) $locale->getpreferredencoding());
var_dump((string) $sys->getdefaultencoding());
var_dump((string) $sys->getfilesystemencoding());
matyhtf commented 9 months ago

需提供参考的技术文档

Yurunsoft commented 9 months ago

Python >= 3.8 对 Py_InitializeEx() 做了改动,参考文档:https://docs.python.org/3/c-api/init_config.html