Syntax
char *CONV_Utf8ToCP1252String(
char *src,
int length,
int *error_code,
size_t *output_length
);
Parameters
- src
- [in] A pointer to a UTF-8 string.
- length
- [in] Specifies the number of bytes to convert. Negative values convert the range until the string pointed to by src ends with a NUL.
- error_code
- [out] A pointer to a variable that returns an error code. Specify NULL when no error code is required.
- output_length
- [out] A pointer to a variable that returns the number of output bytes excluding the NUL at the end of the conversion result. Specify NULL when the number of output bytes is not required.
Return value
Returns a pointer to the buffer that stores the conversion result if the conversion is successful, NULL otherwise.Remarks
Converts a string of the length specified by length from the beginning of the UTF-8 string pointed to by src to a CP1252 string, and returns a pointer to the buffer that stores the conversion result.If you specify a negative value for length, the range until the string pointed to by src ends with NUL is converted.
If a NUL is detected before the string pointed to by src reaches the length specified by length, the string up to the NUL is converted.
If the string pointed to by src contains a character code that cannot be converted to the CP1252, replace that character with '?' and continue the conversion. In this case, it returns the following error code in the variable pointed to by error_code.
Error code | Description |
---|---|
CONV_UNSUPPORTED_CODE_WARNING | It contained a character code that could not be converted. |
If the conversion is successful, end the conversion result string with a NUL and return the number of bytes of the conversion result excluding the NUL to the variable pointed to by output_length.
If the conversion fails, it returns NULL and returns the following error code in the variable pointed to by error_code.
Error code | Desription |
---|---|
CONV_INVALID_PARAMETER_ERROR | Parameter error. |
CONV_MEMORY_ALLOCATION_ERROR | Memory allocation error. |
CONV_INVALID_UTF8_FORMAT_ERROR | A byte sequence that does not meet the UTF-8 standard has been detected. |
If this function returns a value other than NULL, you need to free the buffer with the free function.
Requirements
Header file:
CP1252.hLibrary file:
libCP1252.a
libCodeConversion.a
libSTARTUPOPH5000.a
Last updated: 2022/04/08