String: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - " +\|\$Warning( *)\|" to " |$1Warning$1|") |
(page refresh) |
||
Line 1: | Line 1: | ||
{{ | {{TOC|side}} | ||
= Description = | |||
A '''string''' is the [[:Category:Data Types|variable type]] that can contain text and may consist of any number of ASCII characters and is enclosed by single-quotes (only in {{arma1}}) or double-quotes. In {{ofp}}, strings could alternatively also be written enclosed by curled braces, which are reserved for [[Code]] in {{arma1}}. | |||
{{Feature | arma3 | From {{arma3}} v1.55.133789 strings are limited to maximum of '''9,999,999''' (sometimes 10,000,000) characters}} | |||
''' | |||
== Examples {{ofp}} == | |||
_string = "here is my string" | _string = "here is my string" | ||
_string2 = {It may contain a lot of characters #@$} | _string2 = {It may contain a lot of characters #@$} | ||
== Examples {{arma1}} == | |||
_string = "here is my string" | _string = "here is my string" | ||
_string2 = 'It may contain a lot of characters #@$' | _string2 = 'It may contain a lot of characters #@$' | ||
Line 22: | Line 18: | ||
_string2 = 'my other string "with" quotes' | _string2 = 'my other string "with" quotes' | ||
= Operators = | |||
The only basic operator to be used on strings is "plus". You can use "plus" to concatenate two strings. | The only basic operator to be used on strings is "plus". You can use "plus" to concatenate two strings. | ||
_string = "Hello " + "world" | _string = "Hello " + "world" | ||
= Commands = | |||
You can convert any type to a string using the command [[format]]. You can also use that command to build together a string out of different elements. See the documentation of [[format]] for a closer description. | You can convert any type to a string using the command [[format]]. You can also use that command to build together a string out of different elements. See the documentation of [[format]] for a closer description. | ||
Line 37: | Line 32: | ||
=> ["my","array","of","strings"] | => ["my","array","of","strings"] | ||
= Limitations = | |||
Since '''{{arma1}}''' strings seem not to have any limitation in length. | |||
Since ''' | |||
In '''{{ofp}} v1.96''', manipulating and using strings above 2056 characters in length may crash the game. | |||
Other than double quotes ("text"), single quotes ('text') do not seem to support tabs: | Other than double quotes ("text"), single quotes ('text') do not seem to support tabs: | ||
Line 62: | Line 55: | ||
x" - second tab vanished*/ | x" - second tab vanished*/ | ||
<small>Example by [http://forums.bistudio.com/member.php?81568-Rydygier Rydygier]</small> | |||
== Encoding == | == Encoding == | ||
In {{ofp}} the strings were internally [http://en.wikipedia.org/wiki/ASCII ASCII], and the [http://en.wikipedia.org/wiki/Code_page code page] used was defined by the product language version (by the fonts which were provided with it). | |||
Since {{arma1}} all strings are [http://en.wikipedia.org/wiki/Unicode Unicode], with [http://en.wikipedia.org/wiki/UTF-8 UTF-8] encoding used internally. | |||
{{Feature|informative|The encoding should be mostly transparent. The input files can be encoded both in UTF-16 or UTF-8, the [[toString]] and [[toArray]] functions always convert from/to UTF-16 representation.}} | |||
[[Category: Data Types]] |
Revision as of 17:12, 10 February 2021
Description
A string is the variable type that can contain text and may consist of any number of ASCII characters and is enclosed by single-quotes (only in Armed Assault) or double-quotes. In Operation Flashpoint, strings could alternatively also be written enclosed by curled braces, which are reserved for Code in Armed Assault.
Examples Operation Flashpoint
_string = "here is my string" _string2 = {It may contain a lot of characters #@$}
Examples Armed Assault
_string = "here is my string" _string2 = 'It may contain a lot of characters #@$'
If you want to include double quotes (") in strings enclosed by double quotes, the inside double quotes have to be written twice.
_string = "my string ""with"" quotes" _string2 = 'my other string "with" quotes'
Operators
The only basic operator to be used on strings is "plus". You can use "plus" to concatenate two strings.
_string = "Hello " + "world"
Commands
You can convert any type to a string using the command format. You can also use that command to build together a string out of different elements. See the documentation of format for a closer description.
_string = format ["%1", ["my","array","of","strings"]] hint _string => ["my","array","of","strings"]
Limitations
Since Armed Assault strings seem not to have any limitation in length.
In Operation Flashpoint v1.96, manipulating and using strings above 2056 characters in length may crash the game.
Other than double quotes ("text"), single quotes ('text') do not seem to support tabs:
_string = " "; copyToClipboard _string; diag_log format ["%1 %2 %3 x%4x", toArray _string, toArray copyFromClipboard, toArray (_string select [0]), _string]; /*return is good: "[9,10,9] [9,10,9] [9,10,9] x x"*/
_string = ' '; copyToClipboard _string; diag_log format ["%1 %2 %3 x%4x", toArray _string, toArray copyFromClipboard, toArray (_string select [0]), _string]; /*return: "[9,10] [9,10] [9,10] x x" - second tab vanished*/
Example by Rydygier
Encoding
In Operation Flashpoint the strings were internally ASCII, and the code page used was defined by the product language version (by the fonts which were provided with it).
Since Armed Assault all strings are Unicode, with UTF-8 encoding used internally.