PyUnicode_EncodeDecimal

Takes a Unicode string holding a decimal value and writes it into an output buffer using standard ASCII digit codes.

The output buffer has to provide at least length+1 bytes of storage area. The output string is 0-terminated.

The encoder converts whitespace to ' ', decimal characters to their corresponding ASCII digit and all other Latin-1 characters except \0 as-is. Characters outside this range (Unicode ordinals 1-256) are treated as errors. This includes embedded NULL bytes.

Error handling is defined by the errors argument:

NULL or "strict": raise a ValueError "ignore": ignore the wrong characters (these are not copied to the output buffer) "replace": replaces illegal characters with '?'

Returns 0 on success, -1 on failure.

  1. int PyUnicode_EncodeDecimal(Py_UNICODE* s, Py_ssize_t length, char* output, const(char)* errors)
  2. alias PyUnicode_EncodeDecimal = PyUnicodeUCS2_EncodeDecimal
    version(!Python_3_3_Or_Later && Python_Unicode_UCS2)
    extern (C)
    alias PyUnicode_EncodeDecimal = PyUnicodeUCS2_EncodeDecimal
  3. alias PyUnicode_EncodeDecimal = PyUnicodeUCS4_EncodeDecimal

Meta