Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb093fe

Browse files
committed
M.-A. Lemburg <[email protected]>:
Added PyUnicode_GetDefaultEncoding() and PyUnicode_GetDefaultEncoding() APIs.
1 parent 3ac3edc commit cb093fe

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

Include/unicodeobject.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ extern DL_IMPORT(int) PyUnicode_Resize(
265265
refcount.
266266
267267
2. String and other char buffer compatible objects are decoded
268-
under the assumptions that they contain UTF-8 data. Decoding
269-
is done in "strict" mode.
268+
under the assumptions that they contain data using the current
269+
default encoding. Decoding is done in "strict" mode.
270270
271271
3. All other objects raise an exception.
272272
@@ -313,8 +313,7 @@ extern DL_IMPORT(int) PyUnicode_AsWideChar(
313313
parameters encoding and errors have the same semantics as the ones
314314
of the builtin unicode() API.
315315
316-
Setting encoding to NULL causes the default encoding to be used
317-
which is UTF-8.
316+
Setting encoding to NULL causes the default encoding to be used.
318317
319318
Error handling is set by errors which may also be set to NULL
320319
meaning to use the default handling defined for the codec. Default
@@ -326,6 +325,29 @@ extern DL_IMPORT(int) PyUnicode_AsWideChar(
326325
327326
*/
328327

328+
/* --- Manage the default encoding ---------------------------------------- */
329+
330+
/* Returns the currently active default encoding.
331+
332+
The default encoding is currently implemented as run-time settable
333+
process global. This may change in future versions of the
334+
interpreter to become a parameter which is managed on a per-thread
335+
basis.
336+
337+
*/
338+
339+
extern DL_IMPORT(const char*) PyUnicode_GetDefaultEncoding();
340+
341+
/* Sets the currently active default encoding.
342+
343+
Returns 0 on success, -1 in case of an error.
344+
345+
*/
346+
347+
extern DL_IMPORT(int) PyUnicode_SetDefaultEncoding(
348+
const char *encoding /* Encoding name in standard form */
349+
);
350+
329351
/* --- Generic Codecs ----------------------------------------------------- */
330352

331353
/* Create a Unicode object by decoding the encoded string s of the

0 commit comments

Comments
 (0)