Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

FixedString4096Bytes

struct in Unity.Collections


Implements interfaces:IIndexable<T0>, INativeList<T0>, IUTF8Bytes

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

An unmanaged UTF-8 string whose content is stored directly in the 4096-byte struct.

The binary layout of this string is guaranteed, for now and all time, to be a length (a little-endian two byte integer) followed by the bytes of the characters (with no padding). A zero byte always immediately follows the last character. Effectively, the number of bytes for storing characters is 3 less than 4096 (two length bytes and one null byte).

This layout is identical to a FixedList4096Bytes<T0> of bytes, thus allowing reinterpretation between FixedString4096Bytes and FixedList4096Bytes.

By virtue of being an unmanaged, non-allocated struct with no pointers, this string is fully compatible with jobs and Burst compilation. Unlike managed string types, these strings can be put in any unmanaged ECS components, FixedList, or any other unmanaged structs.

Static Properties

Property Description
UTF8MaxLengthInBytes Returns the maximum number of UTF-8 bytes that can be stored in this string.

Properties

Property Description
Capacity The number of bytes this string has for storing UTF-8 characters.
IsEmpty Returns true if this string is empty (has no characters).
Length The current length in bytes of this string's content.
this[int] Returns the byte (not character) at an index.
Value For internal use only. Use FixedString4096Bytes.ToString instead.

Constructors

Constructor Description
FixedString4096Bytes Initializes and returns an instance of FixedString4096Bytes with the characters copied from a string.

Public Methods

Method Description
Add Appends a byte.
AsFixedList Returns a reference to a FixedList4096Bytes<byte> representation of this string.
Clear Sets the length to 0.
CompareTo Returns the lexicographical sort order of this string relative to another.
ElementAt Returns the reference to a byte (not character) at an index.
Equals Returns true if this string and another have the same length and all the same characters.
GetEnumerator Returns an enumerator for iterating over the characters of this string.
GetHashCode Returns a hash code of this string.
GetUnsafePtr Returns a pointer to the character bytes.
ToString Returns a new managed string that is a copy of this string.
TryResize Attempts to set the length in bytes. Does nothing if the new length is invalid.

Operators

Operator Description
FixedString4096Bytes Returns a new FixedString4096Bytes that is a copy of another string.
operator != Returns true if a FixedString4096Bytes and another string are unequal.
operator == Returns true if a FixedString4096Bytes and another string are equal.