forceUnicode: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *((\[\[[a-zA-Z0-9_ |()]+\]\],? ?)+) * \}\}" to "|seealso= $1 }}")
m (Some wiki formatting)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


|arma3dev
|game1= arma3
|version1= 2.02


|2.01
|gr1= Strings
 
|descr=
<div style="float: right">
List of the commands that work with [[forceUnicode]]:
{{Columns|2|
* [[copyFromClipboard]]
* [[copyToClipboard]]
* [[count]]
* [[find]]
* [[in]]
* [[insert]]
* [[reverse]]
* [[select]]
* [[splitString]]
* [[trim]]
* [[regexFind]]
* [[regexMatch]]
* [[regexReplace]]
}}
</div>
Sets the Unicode flag which forces some of the string manipulation commands to switch to {{Link|https://en.wikipedia.org/wiki/Unicode}}.
The Unicode flag is always set right after [[forceUnicode]] command execution, but is reset depending on the command mode (see ''{{Link|#Syntax 1|mode}}'').
 
When the flag is set it will also affect all scopes within the script including child scopes (see [[diag_scope]]).
There are many other string manipulation commands like [[ctrlSetText]], [[getTextWidth]], etc. that support Unicode by design so no additional forcing is needed.
 
|s1= [[forceUnicode]] mode
 
|p1= mode: [[Number]] - mode of operation, can be:
* -1 - resets previously set Unicode flag
* &nbsp;0 - sets Unicode flag until the end of script
* &nbsp;1 - sets Unicode flag until after next supported command or until the end of script, whichever comes earlier
 
|r1= [[Anything]]
 
|x1= <sqf>
copyToClipboard "д"; // copies "д" to clipboard
forceUnicode 1;
copyToClipboard "д"; // copies "д" to clipboard
</sqf>


|gr1= Strings
|x2= <sqf>
private _string = "привет"; // a string that uses Unicode characters
systemChat str count _string; // 12 - the character count is wrong without forceUnicode


| Switches the mode of operation of the following commands to unicode: [[copyToClipboard]], [[copyFromClipboard]], [[select]], [[count]], [[in]], [[find]], [[splitString]], [[trim]] and [[reverse]].
call {
systemChat str count _string; // 12 - identical result
forceUnicode 0;
systemChat str count _string; // 6 - correct result
};


| [[forceUnicode]] mode
systemChat str count _string; // 6 - outer scope is affected by forceUnicode as well, because the command mode is 0


|p1= mode: [[Number]] - Mode of operation, can be: <br>
forceUnicode -1; // cancelled
* -1 - off
* &nbsp;0 - on until end of script
* &nbsp;1 - on until next compatible command


| [[Anything]]
call {
systemChat str count _string; // 12 - wrong count
forceUnicode 1;
systemChat str count _string; // 6 - correct result, but Unicode it reset after this operation, because command mode is 1
};


|x1= <code>[[copyToClipboard]] "д"; {{cc|Copies "д" to clipboard}}
systemChat str count _string; // 12 - outer scope is not affected as it was reset right after count
[[forceUnicode]] 1; [[copyToClipboard]] "д"; {{cc|Copies "д" to clipboard}}</code>
</sqf>


|seealso= [[copyToClipboard]], [[copyFromClipboard]], [[select]], [[count]], [[in]], [[find]], [[splitString]] [[reverse]]
|seealso= [[copyToClipboard]] [[copyFromClipboard]] [[select]] [[count]] [[in]] [[insert]] [[find]] [[splitString]] [[reverse]]
}}
}}

Latest revision as of 11:43, 30 May 2024

Hover & click on the images for description

Description

Description:

Sets the Unicode flag which forces some of the string manipulation commands to switch to Unicode. The Unicode flag is always set right after forceUnicode command execution, but is reset depending on the command mode (see mode).

When the flag is set it will also affect all scopes within the script including child scopes (see diag_scope).

There are many other string manipulation commands like ctrlSetText, getTextWidth, etc. that support Unicode by design so no additional forcing is needed.
Groups:
Strings

Syntax

Syntax:
forceUnicode mode
Parameters:
mode: Number - mode of operation, can be:
  • -1 - resets previously set Unicode flag
  •  0 - sets Unicode flag until the end of script
  •  1 - sets Unicode flag until after next supported command or until the end of script, whichever comes earlier
Return Value:
Anything

Examples

Example 1:
copyToClipboard "д"; // copies "д" to clipboard forceUnicode 1; copyToClipboard "д"; // copies "д" to clipboard
Example 2:
private _string = "привет"; // a string that uses Unicode characters systemChat str count _string; // 12 - the character count is wrong without forceUnicode call { systemChat str count _string; // 12 - identical result forceUnicode 0; systemChat str count _string; // 6 - correct result }; systemChat str count _string; // 6 - outer scope is affected by forceUnicode as well, because the command mode is 0 forceUnicode -1; // cancelled call { systemChat str count _string; // 12 - wrong count forceUnicode 1; systemChat str count _string; // 6 - correct result, but Unicode it reset after this operation, because command mode is 1 }; systemChat str count _string; // 12 - outer scope is not affected as it was reset right after count

Additional Information

See also:
copyToClipboard copyFromClipboard select count in insert find splitString reverse

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note