'How to find number of character positions in strings with Unicode combining sequences?
python -v: Python 3.8.10
uname -a: Linux ray-desktop 5.11.0-40-generic
#44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021
x86_64 x86_64 x86_64 GNU/Linux
>>> len("Spinal")
6
>>> len("Spi🟩al")
6
>>> len("Spin̈al")
7
This is correctly counting the Unicode green blob as a single character, but the Unicode combining sequence that produces the umlaut-n gets counted as two characters.
How should one handle such things when trying to make monospaced text columns line up?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
