forceUnicode: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Add Leopard20's example)
No edit summary
Line 7: Line 7:
|gr1= Strings
|gr1= Strings


|descr= Switches the mode of operation of the following commands to unicode:
|descr= 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:
* 1 - the Unicode flag is reset right after any of the supported commands executed or the end of script, whichever comes earlier.
* 0 - the Unicode flag is reset at the end of the script.
When the flag is set it will also affect all scopes within the script including child scopes (see also: [[diag_scope]]). There are many other string manipulation commands like [[ctrlSetText]], [[getTextWidth]], etc. that support Unicode by design so no additional forcing is needed.
<br><br>List of the commands that work with [[forceUnicode]]:
<div style="columns: 5">
<div style="columns: 5">
* [[copyFromClipboard]]
* [[copyFromClipboard]]
Line 13: Line 17:
* [[count]]
* [[count]]
* [[find]]
* [[find]]
* [[getTextWidth]]
* [[in]]
* [[in]]
* [[insert]]
* [[insert]]
Line 19: Line 22:
* [[select]]
* [[select]]
* [[splitString]]
* [[splitString]]
* [[trim]]
</div>
</div>
{{Feature | important | [[forceUnicode]] usage with the argument <tt>0</tt> will also apply to [[call]]ed code.}}


|s1= [[forceUnicode]] mode
|s1= [[forceUnicode]] mode


|p1= mode: [[Number]] - Mode of operation, can be: <br>
|p1= mode: [[Number]] - Mode of operation, can be: <br>
* -1 - off
* -1 - resets previously set Unicode flag
* &nbsp;0 - on until end of script
* &nbsp;0 - sets Unicode flag until the end of script
* &nbsp;1 - on until next compatible command
* &nbsp;1 - sets Unicode flag until after next supported command or until the end of script, whichever comes earlier


|r1= [[Anything]]
|r1= [[Anything]]
Line 36: Line 39:
[[copyToClipboard]] "д"; {{cc|Copies "д" to clipboard}}</code>
[[copyToClipboard]] "д"; {{cc|Copies "д" to clipboard}}</code>


|x2= <code>[[private]] _string [[a = b|=]] "привет"; {{cc|a string that uses unicode characters}}
|x2= <code>[[private]] _string [[a = b|=]] "привет"; {{cc|a string that uses Unicode characters}}
[[systemChat]] [[str]] [[count]] _string; {{cc|12 - the character count is wrong without forceUnicode}}
[[systemChat]] [[str]] [[count]] _string; {{cc|12 - the character count is wrong without forceUnicode}}



Revision as of 00:44, 26 February 2021

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:
  • 1 - the Unicode flag is reset right after any of the supported commands executed or the end of script, whichever comes earlier.
  • 0 - the Unicode flag is reset at the end of the script.
When the flag is set it will also affect all scopes within the script including child scopes (see also: diag_scope). There are many other string manipulation commands like ctrlSetText, getTextWidth, etc. that support Unicode by design so no additional forcing is needed.

List of the commands that work with forceUnicode:
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

Additional Information

See also:
copyToClipboardcopyFromClipboardselectcountininsertfindsplitString 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