docs
Docs
C++ API
C API
Search API
Ctrl K
1.4
2.0
latest
1.4
Ultralight C API
1.4.0
Toggle main menu visibility
Loading...
Searching...
No Matches
CAPI_String.h
Go to the documentation of this file.
1
/**************************************************************************************************
2
* This file is a part of Ultralight. *
3
* *
4
* See <https://ultralig.ht> for licensing and more. *
5
* *
6
* (C) 2024 Ultralight, Inc. *
7
**************************************************************************************************/
8
9
///
10
/// @file CAPI_String.h
11
///
12
/// Unicode string container (natively UTF-8).
13
///
14
/// `#include <Ultralight/CAPI/CAPI_String.h>`
15
///
16
/// This class is used to represent strings in Ultralight. It can be created from a variety of
17
/// string types (ASCII, UTF-8, UTF-16) and accessed as a null-terminated UTF-8 buffer.
18
///
19
#ifndef ULTRALIGHT_CAPI_STRING_H
20
#define ULTRALIGHT_CAPI_STRING_H
21
22
#include <
Ultralight/CAPI/CAPI_Defines.h
>
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
28
/******************************************************************************
29
* String
30
*****************************************************************************/
31
32
///
33
/// Create string from null-terminated ASCII C-string.
34
///
35
ULExport
ULString
ulCreateString
(
const
char
* str);
36
37
///
38
/// Create string from UTF-8 buffer.
39
///
40
ULExport
ULString
ulCreateStringUTF8
(
const
char
* str,
size_t
len);
41
42
///
43
/// Create string from UTF-16 buffer.
44
///
45
ULExport
ULString
ulCreateStringUTF16
(
ULChar16
* str,
size_t
len);
46
47
///
48
/// Create string from copy of existing string.
49
///
50
ULExport
ULString
ulCreateStringFromCopy
(
ULString
str);
51
52
///
53
/// Destroy string (you should destroy any strings you explicitly Create).
54
///
55
ULExport
void
ulDestroyString
(
ULString
str);
56
57
///
58
/// Get native UTF-8 buffer data (always null-terminated).
59
///
60
ULExport
char
*
ulStringGetData
(
ULString
str);
61
62
///
63
/// Get length (in bytes) of the UTF-8 buffer data, not including null terminator.
64
///
65
ULExport
size_t
ulStringGetLength
(
ULString
str);
66
67
///
68
/// Whether this string is empty or not.
69
///
70
ULExport
bool
ulStringIsEmpty
(
ULString
str);
71
72
///
73
/// Replaces the contents of 'str' with the contents of 'new_str'
74
///
75
ULExport
void
ulStringAssignString
(
ULString
str,
ULString
new_str);
76
77
///
78
/// Replaces the contents of 'str' with the contents of a C-string.
79
///
80
ULExport
void
ulStringAssignCString
(
ULString
str,
const
char
* c_str);
81
82
#ifdef __cplusplus
83
}
// extern "C"
84
#endif
85
86
#endif
// ULTRALIGHT_CAPI_STRING_H
CAPI_Defines.h
Various defines and utility functions for the C API.
ULChar16
unsigned short ULChar16
Definition
CAPI_Defines.h:52
ULString
struct C_String * ULString
Definition
CAPI_Defines.h:65
ULExport
#define ULExport
Definition
CAPI_Defines.h:38
ulStringGetData
char * ulStringGetData(ULString str)
Get native UTF-8 buffer data (always null-terminated).
ulCreateString
ULString ulCreateString(const char *str)
Create string from null-terminated ASCII C-string.
ulCreateStringUTF16
ULString ulCreateStringUTF16(ULChar16 *str, size_t len)
Create string from UTF-16 buffer.
ulCreateStringFromCopy
ULString ulCreateStringFromCopy(ULString str)
Create string from copy of existing string.
ulStringAssignString
void ulStringAssignString(ULString str, ULString new_str)
Replaces the contents of 'str' with the contents of 'new_str'.
ulStringAssignCString
void ulStringAssignCString(ULString str, const char *c_str)
Replaces the contents of 'str' with the contents of a C-string.
ulCreateStringUTF8
ULString ulCreateStringUTF8(const char *str, size_t len)
Create string from UTF-8 buffer.
ulDestroyString
void ulDestroyString(ULString str)
Destroy string (you should destroy any strings you explicitly Create).
ulStringIsEmpty
bool ulStringIsEmpty(ULString str)
Whether this string is empty or not.
ulStringGetLength
size_t ulStringGetLength(ULString str)
Get length (in bytes) of the UTF-8 buffer data, not including null terminator.
Ultralight
CAPI
CAPI_String.h
Docs
C++ API
C API
Version
1.4
2.0
latest
1.4