# lv_string.h (/api/stdlib/lv_string_h)



<ApiSummary functions="18" />

Functions [#functions]

<ApiMember kind="function" name="lv_memcpy" file="stdlib/lv_string.h" line="39" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L39">
  lv_memcpy [#lv_memcpy]

  Copies a block of memory from a source address to a destination address.

  ```c title=" " lineNumbers=1
  void * lv_memcpy(void *dst, const void *src, size_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                      | Description                                                         |
  | ----- | ------------------------- | ------------------------------------------------------------------- |
  | `dst` | `void *`                  | Pointer to the destination array where the content is to be copied. |
  | `src` | `const void *`            | Pointer to the source of data to be copied.                         |
  | `len` | <ApiLink name="size_t" /> | Number of bytes to copy.                                            |

  **Returns:** `void *` — Pointer to the destination array.

  <Callout type="info">
    The function does not check for any overlapping of the source and destination memory blocks.
  </Callout>
</ApiMember>

<ApiMember kind="function" name="lv_memset" file="stdlib/lv_string.h" line="48" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L48">
  lv_memset [#lv_memset]

  Fills a block of memory with a specified value.

  ```c title=" " lineNumbers=1
  void lv_memset(void *dst, uint8_t v, size_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                       | Description                                                                                                                                  |
  | ----- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
  | `dst` | `void *`                   | Pointer to the destination array to fill with the specified value.                                                                           |
  | `v`   | <ApiLink name="uint8_t" /> | Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value. |
  | `len` | <ApiLink name="size_t" />  | Number of bytes to be set to the value.                                                                                                      |
</ApiMember>

<ApiMember kind="function" name="lv_memmove" file="stdlib/lv_string.h" line="57" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L57">
  lv_memmove [#lv_memmove]

  Move a block of memory from source to destination.

  ```c title=" " lineNumbers=1
  void * lv_memmove(void *dst, const void *src, size_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                      | Description                                                         |
  | ----- | ------------------------- | ------------------------------------------------------------------- |
  | `dst` | `void *`                  | Pointer to the destination array where the content is to be copied. |
  | `src` | `const void *`            | Pointer to the source of data to be copied.                         |
  | `len` | <ApiLink name="size_t" /> | Number of bytes to copy                                             |

  **Returns:** `void *` — Pointer to the destination array.
</ApiMember>

<ApiMember kind="function" name="lv_memcmp" file="stdlib/lv_string.h" line="66" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L66">
  lv_memcmp [#lv_memcmp]

  This function will compare two memory blocks.

  ```c title=" " lineNumbers=1
  int lv_memcmp(const void *p1, const void *p2, size_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                      | Description                        |
  | ----- | ------------------------- | ---------------------------------- |
  | `p1`  | `const void *`            | Pointer to the first memory block  |
  | `p2`  | `const void *`            | Pointer to the second memory block |
  | `len` | <ApiLink name="size_t" /> | Number of bytes to compare         |

  **Returns:** `int` — The difference between the value of the first unmatching byte.
</ApiMember>

<ApiMember kind="function" name="lv_memzero" file="stdlib/lv_string.h" line="73" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L73">
  lv_memzero [#lv_memzero]

  Same as `memset(dst, 0x00, len)`.

  ```c title=" " lineNumbers=1
  static void lv_memzero(void *dst, size_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                      | Description                       |
  | ----- | ------------------------- | --------------------------------- |
  | `dst` | `void *`                  | pointer to the destination buffer |
  | `len` | <ApiLink name="size_t" /> | number of byte to set             |
</ApiMember>

<ApiMember kind="function" name="lv_strlen" file="stdlib/lv_string.h" line="83" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L83">
  lv_strlen [#lv_strlen]

  Computes the length of the string str up to (but not including) the terminating null character.

  ```c title=" " lineNumbers=1
  size_t lv_strlen(const char *str)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type           | Description                                                |
  | ----- | -------------- | ---------------------------------------------------------- |
  | `str` | `const char *` | Pointer to the null-terminated byte string to be examined. |

  **Returns:** <ApiLink name="size_t" /> — The length of the string in bytes.
</ApiMember>

<ApiMember kind="function" name="lv_strnlen" file="stdlib/lv_string.h" line="92" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L92">
  lv_strnlen [#lv_strnlen]

  Computes the length of the string str up to (but not including) the terminating null character, or the given maximum length.

  ```c title=" " lineNumbers=1
  size_t lv_strnlen(const char *str, size_t max_len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name      | Type                      | Description                                                                     |
  | --------- | ------------------------- | ------------------------------------------------------------------------------- |
  | `str`     | `const char *`            | Pointer to byte string that is null-terminated or at least max\_len bytes long. |
  | `max_len` | <ApiLink name="size_t" /> | Maximum number of characters to examine.                                        |

  **Returns:** <ApiLink name="size_t" /> — The length of the string in bytes.
</ApiMember>

<ApiMember kind="function" name="lv_strlcpy" file="stdlib/lv_string.h" line="101" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L101">
  lv_strlcpy [#lv_strlcpy]

  Copies up to dst\_size-1 (non-null) characters from src to dst. A null terminator is always added.

  ```c title=" " lineNumbers=1
  size_t lv_strlcpy(char *dst, const char *src, size_t dst_size)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name       | Type                      | Description                                                                     |
  | ---------- | ------------------------- | ------------------------------------------------------------------------------- |
  | `dst`      | `char *`                  | Pointer to the destination array where the content is to be copied.             |
  | `src`      | `const char *`            | Pointer to the source of data to be copied.                                     |
  | `dst_size` | <ApiLink name="size_t" /> | Maximum number of characters to be copied to dst, including the null character. |

  **Returns:** <ApiLink name="size_t" /> — The length of src. The return value is equivalent to the value returned by lv\_strlen(src)
</ApiMember>

<ApiMember kind="function" name="lv_strncpy" file="stdlib/lv_string.h" line="112" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L112">
  lv_strncpy [#lv_strncpy]

  Copies up to dest\_size characters from the string pointed to by src to the character array pointed to by dst and fills the remaining length with null bytes.

  ```c title=" " lineNumbers=1
  char * lv_strncpy(char *dst, const char *src, size_t dest_size)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name        | Type                      | Description                                                         |
  | ----------- | ------------------------- | ------------------------------------------------------------------- |
  | `dst`       | `char *`                  | Pointer to the destination array where the content is to be copied. |
  | `src`       | `const char *`            | Pointer to the source of data to be copied.                         |
  | `dest_size` | <ApiLink name="size_t" /> | Maximum number of characters to be copied to dst.                   |

  **Returns:** `char *` — A pointer to the destination array, which is dst.

  <Callout type="info">
    dst will not be null terminated if dest\_size bytes were copied from src before the end of src was reached.
  </Callout>
</ApiMember>

<ApiMember kind="function" name="lv_strcpy" file="stdlib/lv_string.h" line="121" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L121">
  lv_strcpy [#lv_strcpy]

  Copies the string pointed to by src, including the terminating null character, to the character array pointed to by dst.

  ```c title=" " lineNumbers=1
  char * lv_strcpy(char *dst, const char *src)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type           | Description                                                         |
  | ----- | -------------- | ------------------------------------------------------------------- |
  | `dst` | `char *`       | Pointer to the destination array where the content is to be copied. |
  | `src` | `const char *` | Pointer to the source of data to be copied.                         |

  **Returns:** `char *` — A pointer to the destination array, which is dst.
</ApiMember>

<ApiMember kind="function" name="lv_strcmp" file="stdlib/lv_string.h" line="129" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L129">
  lv_strcmp [#lv_strcmp]

  This function will compare two strings without specified length.

  ```c title=" " lineNumbers=1
  int lv_strcmp(const char *s1, const char *s2)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type           | Description                  |
  | ---- | -------------- | ---------------------------- |
  | `s1` | `const char *` | pointer to the first string  |
  | `s2` | `const char *` | pointer to the second string |

  **Returns:** `int` — the difference between the value of the first unmatching character.
</ApiMember>

<ApiMember kind="function" name="lv_strncmp" file="stdlib/lv_string.h" line="138" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L138">
  lv_strncmp [#lv_strncmp]

  This function will compare two strings up to the given length.

  ```c title=" " lineNumbers=1
  int lv_strncmp(const char *s1, const char *s2, size_t len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type                      | Description                                 |
  | ----- | ------------------------- | ------------------------------------------- |
  | `s1`  | `const char *`            | pointer to the first string                 |
  | `s2`  | `const char *`            | pointer to the second string                |
  | `len` | <ApiLink name="size_t" /> | the maximum amount of characters to compare |

  **Returns:** `int` — the difference between the value of the first unmatching character.
</ApiMember>

<ApiMember kind="function" name="lv_streq" file="stdlib/lv_string.h" line="146" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L146">
  lv_streq [#lv_streq]

  Returns true if the two strings are equal. Just a wrapper around strcmp for convenience.

  ```c title=" " lineNumbers=1
  static bool lv_streq(const char *s1, const char *s2)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name | Type           | Description                  |
  | ---- | -------------- | ---------------------------- |
  | `s1` | `const char *` | pointer to the first string  |
  | `s2` | `const char *` | pointer to the second string |

  **Returns:** <ApiLink name="bool" /> — true: the strings are equal; false: otherwise
</ApiMember>

<ApiMember kind="function" name="lv_strdup" file="stdlib/lv_string.h" line="156" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L156">
  lv_strdup [#lv_strdup]

  Duplicate a string by allocating a new one and copying the content.

  ```c title=" " lineNumbers=1
  char * lv_strdup(const char *src)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type           | Description                                 |
  | ----- | -------------- | ------------------------------------------- |
  | `src` | `const char *` | Pointer to the source of data to be copied. |

  **Returns:** `char *` — A pointer to the new allocated string. NULL if failed.
</ApiMember>

<ApiMember kind="function" name="lv_strndup" file="stdlib/lv_string.h" line="165" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L165">
  lv_strndup [#lv_strndup]

  Duplicate a string by allocating a new one and copying the content up to the end or the specified maximum length, whichever comes first.

  ```c title=" " lineNumbers=1
  char * lv_strndup(const char *src, size_t max_len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name      | Type                      | Description                                 |
  | --------- | ------------------------- | ------------------------------------------- |
  | `src`     | `const char *`            | Pointer to the source of data to be copied. |
  | `max_len` | <ApiLink name="size_t" /> | Maximum number of characters to be copied.  |

  **Returns:** `char *` — Pointer to a newly allocated null-terminated string. NULL if failed.
</ApiMember>

<ApiMember kind="function" name="lv_strcat" file="stdlib/lv_string.h" line="174" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L174">
  lv_strcat [#lv_strcat]

  Copies the string pointed to by src, including the terminating null character, to the end of the string pointed to by dst.

  ```c title=" " lineNumbers=1
  char * lv_strcat(char *dst, const char *src)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type           | Description                                                            |
  | ----- | -------------- | ---------------------------------------------------------------------- |
  | `dst` | `char *`       | Pointer to the destination string where the content is to be appended. |
  | `src` | `const char *` | Pointer to the source of data to be copied.                            |

  **Returns:** `char *` — A pointer to the destination string, which is dst.
</ApiMember>

<ApiMember kind="function" name="lv_strncat" file="stdlib/lv_string.h" line="186" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L186">
  lv_strncat [#lv_strncat]

  Copies up to src\_len characters from the string pointed to by src to the end of the string pointed to by dst. A terminating null character is appended to dst even if no null character was encountered in src after src\_len characters were copied.

  ```c title=" " lineNumbers=1
  char * lv_strncat(char *dst, const char *src, size_t src_len)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name      | Type                      | Description                                                            |
  | --------- | ------------------------- | ---------------------------------------------------------------------- |
  | `dst`     | `char *`                  | Pointer to the destination string where the content is to be appended. |
  | `src`     | `const char *`            | Pointer to the source of data to be copied.                            |
  | `src_len` | <ApiLink name="size_t" /> | Maximum number of characters from src to be copied to the end of dst.  |

  **Returns:** `char *` — A pointer to the destination string, which is dst.
</ApiMember>

<ApiMember kind="function" name="lv_strchr" file="stdlib/lv_string.h" line="194" url="https://github.com/lvgl/lvgl/tree/a7b95c5b0839ce901c09c205610bc2c77cc3345d/src/stdlib/lv_string.h#L194">
  lv_strchr [#lv_strchr]

  Searches for the first occurrence of character c in the string str.

  ```c title=" " lineNumbers=1
  char * lv_strchr(const char *str, int c)
  ```

  <span className="sr-only">
    Parameters
  </span>

  | Name  | Type           | Description                                                |
  | ----- | -------------- | ---------------------------------------------------------- |
  | `str` | `const char *` | Pointer to the null-terminated byte string to be searched. |
  | `c`   | `int`          | The character to be searched for.                          |

  **Returns:** `char *` — A pointer to the first occurrence of character c in the string str, or a null pointer if c is not found.
</ApiMember>

Dependencies [#dependencies]

<FileIncludes includes="[&#x22;lv_conf_internal.h&#x22;, &#x22;lv_types.h&#x22;]" includedBy="[&#x22;lv_draw_buf.h&#x22;, &#x22;lv_mem.h&#x22;]" transitiveIncludes="[&#x22;lv_conf_kconfig.h&#x22;]" />
