[Python-Dev] C code: %s vs %U
Ethan Furman
ethan at stoneleaf.us
Wed Mar 26 15:07:45 CET 2014
More information about the Python-Dev mailing list
Wed Mar 26 15:07:45 CET 2014
- Previous message: [Python-Dev] C code: %s vs %U
- Next message: [Python-Dev] PEP 466 (round 5): selected network security enhancements for Python 2.7
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 03/26/2014 06:22 AM, � wrote: > [Assuming you are talking about PyUnicode_FromFormatV] >> %s is a string. > > No. %s is a char*; C does not have a "string" type. > The string behind the pointer should be UTF-8 encoded; > other encodings are tolerated through the "replace" error > handler. > >> %U is unicode? > > No. This is a PyObject* whose Python type is 'str' > (i.e. an object for which PyUnicode_Check succeeds) > >> If so, then %s should only be used when it is certain the string in >> question has no unicode in it? > > No. If you have a char*, use %s; using %U would crash. Many thanks! -- ~Ethan~
- Previous message: [Python-Dev] C code: %s vs %U
- Next message: [Python-Dev] PEP 466 (round 5): selected network security enhancements for Python 2.7
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list