New member
- Joined
- Feb 6, 2023
- Messages
- 6
- Thread Author
- #1
Converting any given UTF8 NSRange in a string to a UTF16 NSRange
Examples:
Testing count:
I have only the UTF8 ranges, so what I need is to convert any of them to UTF16 range.
Thank you in advance.
Examples:
Code:
let str = #"let ππ΅π· = "hello world""#
//The UTF8 NSRange of ππ΅π· is: {4, 12}
//The UTF16 NSRange of ππ΅π· is: {4, 6}
//The UTF8 NSRange of let ππ΅π· is: {0, 16}
//The UTF16 NSRange of let ππ΅π· is: {0, 10}
Testing count:
Code:
print("ππ΅π·".utf8.count) //12
print("ππ΅π·".utf16.count) //6
print("let ππ΅π·".utf8.count) //16
print("let ππ΅π·".utf16.count) //10
I have only the UTF8 ranges, so what I need is to convert any of them to UTF16 range.
Thank you in advance.