lynx_value_create_string_utf8

Introduction

Create a string value from a UTF8-encoded C string. The native string is copied.

Syntax

lynx_api_status lynx_value_create_string_utf8(
    lynx_api_env env, const char* str, size_t length, lynx_value* result);

Parameters

KeyDescription
[in] envThe environment in which lynx value runs, typically nullptr.
[in] strCharacter buffer representing a UTF8-encoded string.
[in] lengthThe length of the string in bytes.
[out] resultA lynx_value representing a string.

Return Value

Returns lynx_api_ok if the API succeeded.

Example

It creates an object on the heap, whose memory is managed by reference count, and calls lynx_value_remove_reference to free it when it is used up.

lynx_value val;
lynx_api_status status = lynx_value_create_string_utf8(env, "string", 6, &val);;
if (status != lynx_api_ok) {
  // handle error.
}
// do something.
lynx_value_remove_reference(env, val, NULL);
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.