From fa245be3447acee27db05a96c463ca0047d0ddf7 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 12 Jan 2018 14:16:39 -0600 Subject: [PATCH] Add test for cyrillic; fix funcs with no real chars --- addons/strings/fnc_leftTrim.sqf | 2 +- addons/strings/fnc_rightTrim.sqf | 2 +- addons/strings/test_strings.sqf | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/strings/fnc_leftTrim.sqf b/addons/strings/fnc_leftTrim.sqf index c19d5b0d3..5bf107393 100644 --- a/addons/strings/fnc_leftTrim.sqf +++ b/addons/strings/fnc_leftTrim.sqf @@ -43,7 +43,7 @@ if (_trim == "") then { }; // We have to process the string in array form because it could differ in length (if there are non-ASCII characters) -private _trimIndex = 0; +private _trimIndex = _numChars; { if !(_x in _trim) exitWith { _trimIndex = _forEachIndex; }; } forEach _chars; diff --git a/addons/strings/fnc_rightTrim.sqf b/addons/strings/fnc_rightTrim.sqf index 228419ef8..4881b3bf1 100644 --- a/addons/strings/fnc_rightTrim.sqf +++ b/addons/strings/fnc_rightTrim.sqf @@ -46,7 +46,7 @@ if (_trim == "") then { }; // We have to process the string in array form because it could differ in length (if there are non-ASCII characters) -private _trimIndex = 0; +private _trimIndex = _numChars; { if !(_x in _trim) exitWith { _trimIndex = _forEachIndex; }; } forEach _chars; diff --git a/addons/strings/test_strings.sqf b/addons/strings/test_strings.sqf index 269b67bba..8d59fd46f 100644 --- a/addons/strings/test_strings.sqf +++ b/addons/strings/test_strings.sqf @@ -184,6 +184,10 @@ TEST_OP(_str,==,"",_fn); _str = [" x "] call CBA_fnc_trim; TEST_OP(_str,==,"x",_fn); +// Cyrillic letters (count "РґРµР" = 10) +_str = ["РґРµР", "Р"] call CBA_fnc_trim; +TEST_OP(_str,==,"ґРµ",_fn); + // ---------------------------------------------------------------------------- // UNIT TESTS (capitalize) _fn = "CBA_fnc_capitalize";