Chromium Embedded Framework (CEF)  130.1.2+g48f3ef6+chromium-130.0.6723.44
cef_string_types.h File Reference

CEF provides functions for converting between UTF-8, -16 and -32 strings. More...

#include <stddef.h>
#include <uchar.h>
#include "include/internal/cef_export.h"

Classes

struct  cef_string_wide_t
 CEF string type definitions. More...
 
struct  cef_string_utf8_t
 
struct  cef_string_utf16_t
 

Macros

#define cef_string_wide_copy(src, src_len, output)    cef_string_wide_set(src, src_len, output, true)
 Convenience macros for copying values. More...
 
#define cef_string_utf8_copy(src, src_len, output)    cef_string_utf8_set(src, src_len, output, true)
 
#define cef_string_utf16_copy(src, src_len, output)    cef_string_utf16_set(src, src_len, output, true)
 

Typedefs

typedef cef_string_wide_tcef_string_userfree_wide_t
 It is sometimes necessary for the system to allocate string structures with the expectation that the user will free them. More...
 
typedef cef_string_utf8_tcef_string_userfree_utf8_t
 
typedef cef_string_utf16_tcef_string_userfree_utf16_t
 

Functions

CEF_EXPORT int cef_string_wide_set (const wchar_t *src, size_t src_len, cef_string_wide_t *output, int copy)
 These functions set string values. More...
 
CEF_EXPORT int cef_string_utf8_set (const char *src, size_t src_len, cef_string_utf8_t *output, int copy)
 
CEF_EXPORT int cef_string_utf16_set (const char16_t *src, size_t src_len, cef_string_utf16_t *output, int copy)
 
CEF_EXPORT void cef_string_wide_clear (cef_string_wide_t *str)
 These functions clear string values. More...
 
CEF_EXPORT void cef_string_utf8_clear (cef_string_utf8_t *str)
 
CEF_EXPORT void cef_string_utf16_clear (cef_string_utf16_t *str)
 
CEF_EXPORT int cef_string_wide_cmp (const cef_string_wide_t *str1, const cef_string_wide_t *str2)
 These functions compare two string values with the same results as strcmp(). More...
 
CEF_EXPORT int cef_string_utf8_cmp (const cef_string_utf8_t *str1, const cef_string_utf8_t *str2)
 
CEF_EXPORT int cef_string_utf16_cmp (const cef_string_utf16_t *str1, const cef_string_utf16_t *str2)
 
CEF_EXPORT int cef_string_wide_to_utf8 (const wchar_t *src, size_t src_len, cef_string_utf8_t *output)
 These functions convert between UTF-8, -16, and -32 strings. More...
 
CEF_EXPORT int cef_string_utf8_to_wide (const char *src, size_t src_len, cef_string_wide_t *output)
 
CEF_EXPORT int cef_string_wide_to_utf16 (const wchar_t *src, size_t src_len, cef_string_utf16_t *output)
 
CEF_EXPORT int cef_string_utf16_to_wide (const char16_t *src, size_t src_len, cef_string_wide_t *output)
 
CEF_EXPORT int cef_string_utf8_to_utf16 (const char *src, size_t src_len, cef_string_utf16_t *output)
 
CEF_EXPORT int cef_string_utf16_to_utf8 (const char16_t *src, size_t src_len, cef_string_utf8_t *output)
 
CEF_EXPORT int cef_string_ascii_to_wide (const char *src, size_t src_len, cef_string_wide_t *output)
 These functions convert an ASCII string, typically a hardcoded constant, to a Wide/UTF16 string. More...
 
CEF_EXPORT int cef_string_ascii_to_utf16 (const char *src, size_t src_len, cef_string_utf16_t *output)
 
CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc (void)
 These functions allocate a new string structure. More...
 
CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc (void)
 
CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc (void)
 
CEF_EXPORT void cef_string_userfree_wide_free (cef_string_userfree_wide_t str)
 These functions free the string structure allocated by the associated alloc function. More...
 
CEF_EXPORT void cef_string_userfree_utf8_free (cef_string_userfree_utf8_t str)
 
CEF_EXPORT void cef_string_userfree_utf16_free (cef_string_userfree_utf16_t str)
 
CEF_EXPORT int cef_string_utf16_to_lower (const char16_t *src, size_t src_len, cef_string_utf16_t *output)
 These functions convert utf16 string case using the current ICU locale. More...
 
CEF_EXPORT int cef_string_utf16_to_upper (const char16_t *src, size_t src_len, cef_string_utf16_t *output)
 

Detailed Description

CEF provides functions for converting between UTF-8, -16 and -32 strings.

CEF string types are safe for reading from multiple threads but not for modification. It is the user's responsibility to provide synchronization if modifying CEF strings from multiple threads.

Macro Definition Documentation

◆ cef_string_utf16_copy

#define cef_string_utf16_copy (   src,
  src_len,
  output 
)     cef_string_utf16_set(src, src_len, output, true)

◆ cef_string_utf8_copy

#define cef_string_utf8_copy (   src,
  src_len,
  output 
)     cef_string_utf8_set(src, src_len, output, true)

◆ cef_string_wide_copy

#define cef_string_wide_copy (   src,
  src_len,
  output 
)     cef_string_wide_set(src, src_len, output, true)

Convenience macros for copying values.

Typedef Documentation

◆ cef_string_userfree_utf16_t

◆ cef_string_userfree_utf8_t

◆ cef_string_userfree_wide_t

It is sometimes necessary for the system to allocate string structures with the expectation that the user will free them.

The userfree types act as a hint that the user is responsible for freeing the structure.

Function Documentation

◆ cef_string_ascii_to_utf16()

CEF_EXPORT int cef_string_ascii_to_utf16 ( const char *  src,
size_t  src_len,
cef_string_utf16_t output 
)

◆ cef_string_ascii_to_wide()

CEF_EXPORT int cef_string_ascii_to_wide ( const char *  src,
size_t  src_len,
cef_string_wide_t output 
)

These functions convert an ASCII string, typically a hardcoded constant, to a Wide/UTF16 string.

Use instead of the UTF8 conversion routines if you know the string is ASCII.

◆ cef_string_userfree_utf16_alloc()

CEF_EXPORT cef_string_userfree_utf16_t cef_string_userfree_utf16_alloc ( void  )

◆ cef_string_userfree_utf16_free()

CEF_EXPORT void cef_string_userfree_utf16_free ( cef_string_userfree_utf16_t  str)

◆ cef_string_userfree_utf8_alloc()

CEF_EXPORT cef_string_userfree_utf8_t cef_string_userfree_utf8_alloc ( void  )

◆ cef_string_userfree_utf8_free()

CEF_EXPORT void cef_string_userfree_utf8_free ( cef_string_userfree_utf8_t  str)

◆ cef_string_userfree_wide_alloc()

CEF_EXPORT cef_string_userfree_wide_t cef_string_userfree_wide_alloc ( void  )

These functions allocate a new string structure.

They must be freed by calling the associated free function.

◆ cef_string_userfree_wide_free()

CEF_EXPORT void cef_string_userfree_wide_free ( cef_string_userfree_wide_t  str)

These functions free the string structure allocated by the associated alloc function.

Any string contents will first be cleared.

◆ cef_string_utf16_clear()

CEF_EXPORT void cef_string_utf16_clear ( cef_string_utf16_t str)

◆ cef_string_utf16_cmp()

CEF_EXPORT int cef_string_utf16_cmp ( const cef_string_utf16_t str1,
const cef_string_utf16_t str2 
)

◆ cef_string_utf16_set()

CEF_EXPORT int cef_string_utf16_set ( const char16_t *  src,
size_t  src_len,
cef_string_utf16_t output,
int  copy 
)

◆ cef_string_utf16_to_lower()

CEF_EXPORT int cef_string_utf16_to_lower ( const char16_t *  src,
size_t  src_len,
cef_string_utf16_t output 
)

These functions convert utf16 string case using the current ICU locale.

This may change the length of the string in some cases.

◆ cef_string_utf16_to_upper()

CEF_EXPORT int cef_string_utf16_to_upper ( const char16_t *  src,
size_t  src_len,
cef_string_utf16_t output 
)

◆ cef_string_utf16_to_utf8()

CEF_EXPORT int cef_string_utf16_to_utf8 ( const char16_t *  src,
size_t  src_len,
cef_string_utf8_t output 
)

◆ cef_string_utf16_to_wide()

CEF_EXPORT int cef_string_utf16_to_wide ( const char16_t *  src,
size_t  src_len,
cef_string_wide_t output 
)

◆ cef_string_utf8_clear()

CEF_EXPORT void cef_string_utf8_clear ( cef_string_utf8_t str)

◆ cef_string_utf8_cmp()

CEF_EXPORT int cef_string_utf8_cmp ( const cef_string_utf8_t str1,
const cef_string_utf8_t str2 
)

◆ cef_string_utf8_set()

CEF_EXPORT int cef_string_utf8_set ( const char *  src,
size_t  src_len,
cef_string_utf8_t output,
int  copy 
)

◆ cef_string_utf8_to_utf16()

CEF_EXPORT int cef_string_utf8_to_utf16 ( const char *  src,
size_t  src_len,
cef_string_utf16_t output 
)

◆ cef_string_utf8_to_wide()

CEF_EXPORT int cef_string_utf8_to_wide ( const char *  src,
size_t  src_len,
cef_string_wide_t output 
)

◆ cef_string_wide_clear()

CEF_EXPORT void cef_string_wide_clear ( cef_string_wide_t str)

These functions clear string values.

The structure itself is not freed.

◆ cef_string_wide_cmp()

CEF_EXPORT int cef_string_wide_cmp ( const cef_string_wide_t str1,
const cef_string_wide_t str2 
)

These functions compare two string values with the same results as strcmp().

◆ cef_string_wide_set()

CEF_EXPORT int cef_string_wide_set ( const wchar_t *  src,
size_t  src_len,
cef_string_wide_t output,
int  copy 
)

These functions set string values.

If |copy| is true (1) the value will be copied instead of referenced. It is up to the user to properly manage the lifespan of references.

◆ cef_string_wide_to_utf16()

CEF_EXPORT int cef_string_wide_to_utf16 ( const wchar_t *  src,
size_t  src_len,
cef_string_utf16_t output 
)

◆ cef_string_wide_to_utf8()

CEF_EXPORT int cef_string_wide_to_utf8 ( const wchar_t *  src,
size_t  src_len,
cef_string_utf8_t output 
)

These functions convert between UTF-8, -16, and -32 strings.

They are potentially slow so unnecessary conversions should be avoided. The best possible result will always be written to |output| with the boolean return value indicating whether the conversion is 100% valid.