.isalpha() works for ascii only :-(
Posted: Tue Oct 16, 2018 7:09 pm
With Python2 I did count the "word" characters in Unicode today as 99537 (those with .isalpha() returning True).
Here I did count again, for whole Unicode set, for first 256 and for first 128 unicode characters:
In MicroPython the chr() function does what unichr() does in Python2.
But .isalpha() counts are the same for first 128 and first 256 Unicode characters, and we have just seen that they really are 117 and 52:
So this experimentally proves that .isalpha() seems to be restricted to ASCII.
If that is correct, is there an alternative in MicroPython() that works as .isalpha() in Python2?
Here I did count again, for whole Unicode set, for first 256 and for first 128 unicode characters:
Code: Select all
>>> for i in 0x10ffff, 0xff, 0x7f:
... c=0
... for j in range(i+1):
... if unichr(j).isalpha():
... c+=1
... print(c)
...
99537
117
52
>>>
In MicroPython the chr() function does what unichr() does in Python2.
But .isalpha() counts are the same for first 128 and first 256 Unicode characters, and we have just seen that they really are 117 and 52:
Code: Select all
>>>
MicroPython v1.9.4-272-g46091b8a on 2018-07-18; ESP module with ESP8266
Type "help()" for more information.
>>> for i in 0xff, 0x7f:
... c=0
... for j in range(i+1):
... if chr(j).isalpha():
... c+=1
...
...
... print(c)
...
...
...
52
52
>>> print(chr(8364))
€
>>>
If that is correct, is there an alternative in MicroPython() that works as .isalpha() in Python2?