Add test for utf16CharMap

This commit is contained in:
Veronica Berglyd Olsen
2025-07-05 17:18:04 +02:00
parent 7a90ef8bc4
commit 3c8a0ace60
2 changed files with 14 additions and 6 deletions
+4 -4
View File
@@ -500,13 +500,13 @@ def utf16CharMap(text: str) -> list[int]:
ASCII, UCS-2 or UCS-4. QStrings are in UTF-16, so wide characters
use 2 indices, and thus creates an offset.
"""
posMap = list(range(0, len(text) + 1))
utf16Map = list(range(0, len(text) + 1))
offset = 0
for i, c in enumerate(text):
for i, c in enumerate(text, 1):
if ord(c) > 0xffff:
offset += 1
posMap[i + 1] = i + 1 + offset
return posMap
utf16Map[i] = i + offset
return utf16Map
##