Implement searching for unicode characters by name

This commit is contained in:
Kovid Goyal
2018-02-12 14:08:54 +05:30
parent 193ac6cd81
commit dab852c412
3 changed files with 135 additions and 47 deletions

View File

@@ -27,7 +27,7 @@ codepoints_for_word(const char *word, size_t len) {
for (unsigned short i = 1; i <= words[0]; i++) {
unsigned short word_idx = words[i];
const char *w = idx_to_word[word_idx];
if(strncmp(word, w, len) == 0) {
if (strncmp(word, w, len) == 0 && strlen(w) == len) {
const char_type* codepoints = codepoints_for_word_idx[word_idx];
for (char_type i = 1; i <= codepoints[0]; i++) {
PyObject *t = PyLong_FromUnsignedLong(codepoints[i]); if (t == NULL) { Py_DECREF(ans); return NULL; }