docs
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
21
22#ifdef __cplusplus
23extern "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///
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///
48ULExport 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///
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///
69
70///
71/// Destroy a string previously created with ulCreateString(), ulCreateStringUTF8(),
72/// ulCreateStringUTF16(), or ulCreateStringFromCopy().
73///
74/// @param str The string to destroy.
75///
77
78///
79/// Get native UTF-8 buffer data (always null-terminated).
80///
82
83///
84/// Get length (in bytes) of the UTF-8 buffer data, not including null terminator.
85///
87
88///
89/// Whether this string is empty or not.
90///
92
93///
94/// Replaces the contents of 'str' with the contents of 'new_str'
95///
97
98///
99/// Replaces the contents of 'str' with the contents of a C-string.
100///
101ULExport void ulStringAssignCString(ULString str, const char* c_str);
102
103#ifdef __cplusplus
104} // extern "C"
105#endif
106
107#endif // ULTRALIGHT_CAPI_STRING_H
char * ulStringGetData(ULString str)
Get native UTF-8 buffer data (always null-terminated).
ULString ulCreateString(const char *str)
Create string from a null-terminated UTF-8 C-string.
ULString ulCreateStringUTF16(const ULChar16 *str, size_t len)
Create string from UTF-16 buffer with explicit length.
ULString ulCreateStringFromCopy(ULString str)
Create string from copy of existing string.
void ulStringAssignString(ULString str, ULString new_str)
Replaces the contents of 'str' with the contents of 'new_str'.
void ulStringAssignCString(ULString str, const char *c_str)
Replaces the contents of 'str' with the contents of a C-string.
ULString ulCreateStringUTF8(const char *str, size_t len)
Create string from UTF-8 buffer with explicit length.
void ulDestroyString(ULString str)
Destroy a string previously created with ulCreateString(), ulCreateStringUTF8(), ulCreateStringUTF16(...
bool ulStringIsEmpty(ULString str)
Whether this string is empty or not.
size_t ulStringGetLength(ULString str)
Get length (in bytes) of the UTF-8 buffer data, not including null terminator.
Various defines and utility functions for the C API.
unsigned short ULChar16
Definition CAPI_Defines.h:67
struct C_String * ULString
Opaque handle to a String object.
Definition CAPI_Defines.h:96
#define ULExport
Definition CAPI_Defines.h:42