# toArray ## Category String ## Arity **Unary** — `toArray `. ``` toArray ``` ## Description Converts a string to an array of character codes (ASCII/Unicode code points as integers). Each character becomes one integer element in the result array. Empty string → empty array. ## How It Works Iterates each `char` in the string, casts to `int`, and collects into a new array. For characters above U+FFFF (surrogate pairs), each surrogate half is a separate element. ## Usage ### Basic conversion ```sqf toArray "AB"; // [65, 66] toArray "Hello"; // [72, 101, 108, 108, 111] toArray ""; // [] ``` ### Character-by-character processing ```sqf _codes = toArray _name; _codes forEach { systemChat f"Char code: {_x}"; }; ``` ### Case checking via codes ```sqf _codes = toArray _name; _firstCode = _codes select 0; _isUpper = _firstCode >= 65 && _firstCode <= 90; ``` ### Round-trip with toString ```sqf _original = "Test"; _codes = toArray _original; _restored = toString _codes; // "Test" _original == _restored; // true ``` ## Thread Safety ReadOnly — pure computation, returns new array. Safe from any scheduler. ## See Also - [toString](toString.md) — reverse: array of codes to string - [count](count.md) — string length - [select](select.md) — character at index