2 ms·
Hi, thanks for the interesting submission! I was a bit confused by the detour via utf-8 to arrive at the code points and had to look up UTF-8 encoding first to
by mofeien 2y ago
Hi, thanks for the interesting submission!
I was a bit confused by the detour via utf-8 to arrive at the code points and had to look up UTF-8 encoding first to understand how they relate. Then I tried out the following
candidate = chr(0xD800)
candidate2 = bytes([0xED, 0xA0, 0x80]).decode('utf-8', errors='surrogatepass')
print(candidate == candidate2) # True
and it seems that you could just iterate over code points directly with the `chr()` function.
- feldrim 2y agoI f I remember correctly, I tried that but in order to cover the exact range I need, the high and low surrogates, I picked this way out of practicality. It was just easier.