Use UTF-8 as the system encoding on VxWorks.
The main reason are:
1. The locale is frequently misconfigured.
2. Missing some functions to deal with locale in VxWorks C library.
Encoding, highest priority to lowest priority:
- * ``UTF-8`` on macOS and Android;
+ * ``UTF-8`` on macOS, Android, and VxWorks;
* ``UTF-8`` on Windows if :c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
* ``UTF-8`` if the Python UTF-8 mode is enabled;
* ``ASCII`` if the ``LC_CTYPE`` locale is ``"C"``,
Encoding, highest priority to lowest priority:
- * ``UTF-8`` on macOS and Android;
+ * ``UTF-8`` on macOS, Android, and VxWorks;
* ``UTF-8`` on Windows if :c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
* ``UTF-8`` if the Python UTF-8 mode is enabled;
* ``ASCII`` if the ``LC_CTYPE`` locale is ``"C"``,
Py_ssize_t len, \
const char *errors)
- Decode a string from UTF-8 on Android, or from the current locale encoding
- on other platforms. The supported
+ Decode a string from UTF-8 on Android and VxWorks, or from the current
+ locale encoding on other platforms. The supported
error handlers are ``"strict"`` and ``"surrogateescape"``
(:pep:`383`). The decoder uses ``"strict"`` error handler if
*errors* is ``NULL``. *str* must end with a null character but
.. c:function:: PyObject* PyUnicode_EncodeLocale(PyObject *unicode, const char *errors)
- Encode a Unicode object to UTF-8 on Android, or to the current locale
- encoding on other platforms. The
+ Encode a Unicode object to UTF-8 on Android and VxWorks, or to the current
+ locale encoding on other platforms. The
supported error handlers are ``"strict"`` and ``"surrogateescape"``
(:pep:`383`). The encoder uses ``"strict"`` error handler if
*errors* is ``NULL``. Return a :class:`bytes` object. *unicode* cannot
* In the UTF-8 mode, the encoding is ``utf-8`` on any platform.
- * On Mac OS X, the encoding is ``'utf-8'``.
+ * On macOS, the encoding is ``'utf-8'``.
* On Unix, the encoding is the locale encoding.
* On Windows, the encoding may be ``'utf-8'`` or ``'mbcs'``, depending
on user configuration.
+ * On Android, the encoding is ``'utf-8'``.
+
+ * On VxWorks, the encoding is ``'utf-8'``.
+
.. versionchanged:: 3.2
:func:`getfilesystemencoding` result cannot be ``None`` anymore.
Linux ``'linux'``
Windows ``'win32'``
Windows/Cygwin ``'cygwin'``
- Mac OS X ``'darwin'``
+ macOS ``'darwin'``
================ ===========================
.. versionchanged:: 3.3
* The UTF-8 Mode uses UTF-8/surrogateescape;
* If Python forces the usage of the ASCII encoding (ex: C locale
or POSIX locale on FreeBSD or HP-UX), use ASCII/surrogateescape;
- * locale encoding: ANSI code page on Windows, UTF-8 on Android,
- LC_CTYPE locale encoding on other platforms;
+ * locale encoding: ANSI code page on Windows, UTF-8 on Android and
+ VxWorks, LC_CTYPE locale encoding on other platforms;
* On Windows, "surrogateescape" error handler;
* "surrogateescape" error handler if the LC_CTYPE locale is "C" or "POSIX";
* "surrogateescape" error handler if the LC_CTYPE locale has been coerced
--- /dev/null
+Use UTF-8 as the system encoding on VxWorks.
#ifdef MS_WINDOWS
char encoding[20];
PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
-#elif defined(__ANDROID__)
+#elif defined(__ANDROID__) || defined(__VXWORKS__)
const char *encoding = "UTF-8";
#else
const char *encoding = nl_langinfo(CODESET);
int current_locale, _Py_error_handler errors)
{
if (current_locale) {
-#ifdef __ANDROID__
+#if defined(__ANDROID__) || defined(__VXWORKS__)
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
errors);
#else
#endif
}
-#if defined(__APPLE__) || defined(__ANDROID__)
+#if defined(__APPLE__) || defined(__ANDROID__) || defined(__VXWORKS__)
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
errors);
#else
#endif
return decode_current_locale(arg, wstr, wlen, reason, errors);
-#endif /* __APPLE__ or __ANDROID__ */
+#endif /* __APPLE__ or __ANDROID__ or __VXWORKS__ */
}