Function

GLibutf8_strncpy

Declaration

gchar*
g_utf8_strncpy (
  gchar* dest,
  const gchar* src,
  gsize n
)

Description

Like the standard C strncpy() function, but copies a given number of characters instead of a given number of bytes. The src string must be valid UTF-8 encoded text. (Use g_utf8_validate() on all text before trying to use UTF-8 utility functions with it.)

Note you must ensure dest is at least 4 * n to fit the largest possible UTF-8 characters.

Parameters

dest gchar*
 

Buffer to fill with characters from src.

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
src const gchar*
 

UTF-8 encoded string.

 The data is owned by the caller of the function.
 The string is a NUL terminated UTF-8 string.
n gsize
 

Character count.

Return value

Returns: utf8
 

dest.

 The data is owned by the called function.
 The string is a NUL terminated UTF-8 string.