VLC  3.0.15
Functions
unicode.c File Reference
Include dependency graph for unicode.c:

Functions

int utf8_vfprintf (FILE *stream, const char *fmt, va_list ap)
 Formats an UTF-8 string as vfprintf(), then print it, with appropriate conversion to local encoding. More...
 
int utf8_fprintf (FILE *stream, const char *fmt,...)
 Formats an UTF-8 string as fprintf(), then print it, with appropriate conversion to local encoding. More...
 
size_t vlc_towc (const char *str, uint32_t *restrict pwc)
 Decodes a code point from UTF-8. More...
 
char * vlc_strcasestr (const char *haystack, const char *needle)
 Look for an UTF-8 string within another one in a case-insensitive fashion. More...
 
char * FromCharset (const char *charset, const void *data, size_t data_size)
 Converts a string from the given character encoding to utf-8. More...
 
void * ToCharset (const char *charset, const char *in, size_t *outsize)
 Converts a nul-terminated UTF-8 string to a given character encoding. More...
 

Function Documentation

◆ FromCharset()

char* FromCharset ( const char *  charset,
const void *  data,
size_t  data_size 
)

Converts a string from the given character encoding to utf-8.

Returns
a nul-terminated utf-8 string, or null in case of error. The result must be freed using free().

References vlc_iconv(), vlc_iconv_close(), and vlc_iconv_open().

Referenced by vlc_readdir().

◆ ToCharset()

void* ToCharset ( const char *  charset,
const char *  in,
size_t *  outsize 
)

Converts a nul-terminated UTF-8 string to a given character encoding.

Parameters
charseticonv name of the character set
innul-terminated UTF-8 string
outsizepointer to hold the byte size of result
Returns
A pointer to the result, which must be released using free(). The UTF-8 nul terminator is included in the conversion if the target character encoding supports it. However it is not included in the returned byte size. In case of error, NULL is returned and the byte size is undefined.

References unlikely, vlc_iconv(), vlc_iconv_close(), and vlc_iconv_open().

◆ utf8_fprintf()

int utf8_fprintf ( FILE *  stream,
const char *  fmt,
  ... 
)

Formats an UTF-8 string as fprintf(), then print it, with appropriate conversion to local encoding.

References vlc_memstream::stream, and utf8_vfprintf().

◆ utf8_vfprintf()

int utf8_vfprintf ( FILE *  stream,
const char *  fmt,
va_list  ap 
)

Formats an UTF-8 string as vfprintf(), then print it, with appropriate conversion to local encoding.

References likely, vlc_memstream::stream, unlikely, and vasprintf().

Referenced by utf8_fprintf().

◆ vlc_strcasestr()

char* vlc_strcasestr ( const char *  haystack,
const char *  needle 
)

Look for an UTF-8 string within another one in a case-insensitive fashion.

Beware that this is quite slow. Contrary to strcasestr(), this function works regardless of the system character encoding, and handles multibyte code points correctly.

Parameters
haystackstring to look into
needlestring to look for
Returns
a pointer to the first occurrence of the needle within the haystack, or NULL if no occurrence were found.

References unlikely, and vlc_towc().

Referenced by playlist_LiveSearchUpdateInternal().

◆ vlc_towc()

size_t vlc_towc ( const char *  str,
uint32_t *restrict  pwc 
)

Decodes a code point from UTF-8.

Converts the first character in a UTF-8 sequence into a Unicode code point.

Parameters
stran UTF-8 bytes sequence [IN]
pwcaddress of a location to store the code point [OUT]
Returns
the number of bytes occupied by the decoded code point
Return values
(size_t)-1not a valid UTF-8 sequence
0null character (i.e. str points to an empty string)
1(non-null) ASCII character
2-4non-ASCII character

Referenced by EnsureUTF8(), IsUTF8(), vlc_str2keycode(), and vlc_strcasestr().