String conversion functions¶
-
group
group_string_func
The string utilities module is a collection of string conversion helpers to convert between integer and strings.
Functions
-
uint32_t
cy_generic_string_to_unsigned
(const char *str)¶ Convert a decimal or hexidecimal string to an integer.
- Parameters
str – [in] The string containing the value.
- Returns
The value represented by the string.
-
uint8_t
cy_string_to_signed
(const char *string, uint16_t str_length, int32_t *value_out, uint8_t is_hex)¶ Converts a decimal/hexidecimal string (with optional sign) to a signed long int Better than strtol or atol or atoi because the return value indicates if an error occurred.
- Parameters
string – [in] : The string buffer to be converted
str_length – [in] : The maximum number of characters to process in the string buffer
value_out – [out] : The unsigned in that will receive value of the the decimal string
is_hex – [in] : 0 = Decimal string, 1 = Hexidecimal string
- Returns
the number of characters successfully converted (including sign). i.e. 0 = error
-
uint8_t
cy_string_to_unsigned
(const char *string, uint8_t str_length, uint32_t *value_out, uint8_t is_hex)¶ Converts a decimal/hexidecimal string to an unsigned long int Better than strtol or atol or atoi because the return value indicates if an error occurred.
- Parameters
string – [in] : The string buffer to be converted
str_length – [in] : The maximum number of characters to process in the string buffer
value_out – [out] : The unsigned in that will receive value of the the decimal string
is_hex – [in] : 0 = Decimal string, 1 = Hexidecimal string
- Returns
the number of characters successfully converted. i.e. 0 = error
-
uint32_t