ProtoFlux:Get Character: Difference between revisions

From Resonite Wiki
add warning about strings containing characters outside the basic multilingual plane
m code point -> code unit, add UTF-16 link
Line 28: Line 28:
The character from <code>Str</code> at index <code>Index</code>. If <code>Index</code> is greater than or equal to the length of <code>Str</code>, or if <code>Str</code> is empty or null, the output will be a character with value <code>0</code>.
The character from <code>Str</code> at index <code>Index</code>. If <code>Index</code> is greater than or equal to the length of <code>Str</code>, or if <code>Str</code> is empty or null, the output will be a character with value <code>0</code>.


{{Template:Note|Strings are UTF-16 encoded, and a char represents one UTF16 codepoint. Usage of this node on a string containing characters outside the [https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane Basic Multilingual Plane] may result in unwanted or confusing behavior, such as returning a surrogate.|warning}}
{{Template:Note|Strings are [[UTF-16]] encoded, and a char represents one UTF-16 code unit. Usage of this node on a string containing characters outside the [https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane Basic Multilingual Plane] may result in unwanted or confusing behavior, such as returning a surrogate.|warning}}


== Examples ==
== Examples ==

Revision as of 17:57, 17 April 2024

Get Character
Str
*
Index
Characters

Get Character is a ProtoFlux node that retrieves an arbitrary character from a given string.

Inputs

Str (String)

The string to retrieve a character from.

Index (int)

The 0-indexed character to retrieve from Str.

Outputs

* (char)

The character from Str at index Index. If Index is greater than or equal to the length of Str, or if Str is empty or null, the output will be a character with value 0.

Strings are UTF-16 encoded, and a char represents one UTF-16 code unit. Usage of this node on a string containing characters outside the Basic Multilingual Plane may result in unwanted or confusing behavior, such as returning a surrogate.

Examples