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.

Return

The value represented by the string.

Parameters
  • [in] str: The string containing the value.

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.

Return

the number of characters successfully converted (including sign). i.e. 0 = error

Parameters
  • [in] string: : The string buffer to be converted

  • [in] str_length: : The maximum number of characters to process in the string buffer

  • [out] value_out: : The unsigned in that will receive value of the the decimal string

  • [in] is_hex: : 0 = Decimal string, 1 = Hexidecimal string

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.

Return

the number of characters successfully converted. i.e. 0 = error

Parameters
  • [in] string: : The string buffer to be converted

  • [in] str_length: : The maximum number of characters to process in the string buffer

  • [out] value_out: : The unsigned in that will receive value of the the decimal string

  • [in] is_hex: : 0 = Decimal string, 1 = Hexidecimal string