docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
CAPI_String.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
6
///
7
/// @file CAPI_String.h
8
///
9
/// Unicode string container (natively UTF-8).
10
///
11
/// `#include <Ultralight/CAPI/CAPI_String.h>`
12
///
13
/// ULString is an opaque handle representing a Unicode string in Ultralight. It can be created
14
/// from a variety of string types (ASCII, UTF-8, UTF-16) and accessed as a null-terminated UTF-8
15
/// buffer.
16
///
17
#ifndef ULTRALIGHT_CAPI_STRING_H
18
#define ULTRALIGHT_CAPI_STRING_H
19
20
#include <
Ultralight/CAPI/CAPI_Defines.h
>
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
/******************************************************************************
27
* String
28
*****************************************************************************/
29
30
///
31
/// Create string from a null-terminated UTF-8 C-string.
32
///
33
/// @param str A null-terminated UTF-8 C-string.
34
///
35
/// @return A new ULString instance. You must call ulDestroyString() when finished.
36
///
37
ULExport
ULString
ulCreateString
(
const
char
* str);
38
39
///
40
/// Create string from UTF-8 buffer with explicit length.
41
///
42
/// @param str Pointer to a UTF-8 encoded buffer (does not need to be null-terminated).
43
///
44
/// @param len Length of the buffer in bytes.
45
///
46
/// @return A new ULString instance. You must call ulDestroyString() when finished.
47
///
48
ULExport
ULString
ulCreateStringUTF8
(
const
char
* str,
size_t
len);
49
50
///
51
/// Create string from UTF-16 buffer with explicit length.
52
///
53
/// @param str Pointer to a UTF-16 encoded buffer.
54
///
55
/// @param len Length of the buffer in characters (not bytes).
56
///
57
/// @return A new ULString instance. You must call ulDestroyString() when finished.
58
///
59
ULExport
ULString
ulCreateStringUTF16
(
const
ULChar16
* str,
size_t
len);
60
61
///
62
/// Create string from copy of existing string.
63
///
64
/// @param str The string to copy.
65
///
66
/// @return A new ULString instance. You must call ulDestroyString() when finished.
67
///
68
ULExport
ULString
ulCreateStringFromCopy
(
ULString
str);
69
70
///
71
/// Destroy a string previously created with ulCreateString(), ulCreateStringUTF8(),
72
/// ulCreateStringUTF16(), or ulCreateStringFromCopy().
73
///
74
/// @param str The string to destroy.
75
///
76
ULExport
void
ulDestroyString
(
ULString
str);
77
78
///
79
/// Get native UTF-8 buffer data (always null-terminated).
80
///
81
ULExport
char
*
ulStringGetData
(
ULString
str);
82
83
///
84
/// Get length (in bytes) of the UTF-8 buffer data, not including null terminator.
85
///
86
ULExport
size_t
ulStringGetLength
(
ULString
str);
87
88
///
89
/// Whether this string is empty or not.
90
///
91
ULExport
bool
ulStringIsEmpty
(
ULString
str);
92
93
///
94
/// Replaces the contents of 'str' with the contents of 'new_str'
95
///
96
ULExport
void
ulStringAssignString
(
ULString
str,
ULString
new_str);
97
98
///
99
/// Replaces the contents of 'str' with the contents of a C-string.
100
///
101
ULExport
void
ulStringAssignCString
(
ULString
str,
const
char
* c_str);
102
103
#ifdef __cplusplus
104
}
// extern "C"
105
#endif
106
107
#endif
// ULTRALIGHT_CAPI_STRING_H
ulStringGetData
char * ulStringGetData(ULString str)
Get native UTF-8 buffer data (always null-terminated).
ulCreateString
ULString ulCreateString(const char *str)
Create string from a null-terminated UTF-8 C-string.
ulCreateStringUTF16
ULString ulCreateStringUTF16(const ULChar16 *str, size_t len)
Create string from UTF-16 buffer with explicit length.
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 with explicit length.
ulDestroyString
void ulDestroyString(ULString str)
Destroy a string previously created with ulCreateString(), ulCreateStringUTF8(), ulCreateStringUTF16(...
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.
CAPI_Defines.h
Various defines and utility functions for the C API.
ULChar16
unsigned short ULChar16
Definition
CAPI_Defines.h:67
ULString
struct C_String * ULString
Opaque handle to a String object.
Definition
CAPI_Defines.h:96
ULExport
#define ULExport
Definition
CAPI_Defines.h:42
Ultralight
CAPI
CAPI_String.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4