A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2014-March/133521.html below:

[Python-Dev] C code: %s vs %U

[Python-Dev] C code: %s vs %U [Python-Dev] C code: %s vs %U"Martin v. Löwis" martin at v.loewis.de
Wed Mar 26 14:22:13 CET 2014
[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.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4