git » sdk » commit 98d964e

Fix for when index is zero

author Stephen Paul Weber
2025-11-12 20:19:16 UTC
committer Stephen Paul Weber
2025-11-12 20:19:16 UTC
parent 3da8ec2b1c1ad5360646ffd91e52534deb0ec76c

Fix for when index is zero

borogove/Util.hx +2 -2

diff --git a/borogove/Util.hx b/borogove/Util.hx
index 9ee1e10..7697a94 100644
--- a/borogove/Util.hx
+++ b/borogove/Util.hx
@@ -178,14 +178,14 @@ class Util {
 		var unicodeOffset = 0;
 		var nativeOffset = 0;
 		while (nativeOffset < s.length) {
-			unicodeOffset++;
-			var c = StringTools.utf16CodePointAt(s, nativeOffset++);
 			if (nativeOffset == index) {
 				return unicodeOffset;
 			}
+			var c = StringTools.utf16CodePointAt(s, nativeOffset++);
 			if (c >= StringTools.MIN_SURROGATE_CODE_POINT) {
 				nativeOffset++;
 			}
+			unicodeOffset++;
 		}
 
 		if (nativeOffset == index) {