Type:String: Difference between revisions

From Resonite Wiki
Merging some text from Editing Types:String
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A String is a sequence of [[char]] values in UTF-16, and is seen in C# (which Resonite is written in). A String is considered an object not a value internally and when choosing the difference between an object or a value, it is an object. In the case of choosing between only either a reference or a value, it is under value.
The '''string''' type is a direct interface to [https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/ the same type in C#].


Strings are considered an [[Type:object|object]] rather than a primitive, and as such one should use the corresponding object components and ProtoFlux nodes to interface with them. However, if one needs to choose a difference between a reference and value for the string type, it is a value.


A String can be made in [[ProtoFlux]] by concatenating different Strings together, or by concatenating 2 or more [[char]] objects together.
Strings are sequences of [[Type:char|chars]], and as such are [https://en.wikipedia.org/wiki/UTF-16 UTF-16] encoded. When representing characters that are outside the [https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane Basic Multilingual Plane], a pair of two <code>char</code>s is used, known as a [https://en.wikipedia.org/wiki/Surrogate_pair#U+D800_to_U+DFFF_(surrogates) surrogate pair]. Due to this, not every character in a string may be mapped directly to one <code>char</code>, and this can cause confusion when using ProtoFlux nodes on strings containing non-BMP characters. Additionally, stray surrogate characters that are not part of a surrogate pair may not behave as intended.


Note: If you are willing to handle "special characters" which requires "surrogate pairs" to express it in UTF-16, you may want to use String To UTF32 (ProtoFlux Node).
Most string-displaying components have an option for [[Rich Text Formatting]], which allow users to put in HTML-like codes to change the style of the text.
 
== See Also ==
* [[:Category:ProtoFlux:Strings]]

Latest revision as of 15:44, 24 September 2024

The string type is a direct interface to the same type in C#.

Strings are considered an object rather than a primitive, and as such one should use the corresponding object components and ProtoFlux nodes to interface with them. However, if one needs to choose a difference between a reference and value for the string type, it is a value.

Strings are sequences of chars, and as such are UTF-16 encoded. When representing characters that are outside the Basic Multilingual Plane, a pair of two chars is used, known as a surrogate pair. Due to this, not every character in a string may be mapped directly to one char, and this can cause confusion when using ProtoFlux nodes on strings containing non-BMP characters. Additionally, stray surrogate characters that are not part of a surrogate pair may not behave as intended.

Most string-displaying components have an option for Rich Text Formatting, which allow users to put in HTML-like codes to change the style of the text.

See Also