Fix character names for control characters not being read from unicode database
Also allow unicode_names.c to be compiled with python 2 so I can re-use it in calibre.
This commit is contained in:
parent
aa93c3fb66
commit
f7001ea068
@ -55,7 +55,9 @@ def parse_ucd():
|
|||||||
for line in get_data('ucd/UnicodeData.txt'):
|
for line in get_data('ucd/UnicodeData.txt'):
|
||||||
parts = [x.strip() for x in line.split(';')]
|
parts = [x.strip() for x in line.split(';')]
|
||||||
codepoint = int(parts[0], 16)
|
codepoint = int(parts[0], 16)
|
||||||
name = parts[1]
|
name = parts[1] or parts[10]
|
||||||
|
if name == '<control>':
|
||||||
|
name = parts[10]
|
||||||
if name:
|
if name:
|
||||||
name_map[codepoint] = name
|
name_map[codepoint] = name
|
||||||
for word in name.lower().split():
|
for word in name.lower().split():
|
||||||
|
|||||||
31921
kittens/unicode_input/names.h
generated
31921
kittens/unicode_input/names.h
generated
File diff suppressed because one or more lines are too long
@ -85,12 +85,13 @@ nfc(PyObject *self UNUSED, PyObject *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef module_methods[] = {
|
static PyMethodDef module_methods[] = {
|
||||||
METHODB(all_words, METH_NOARGS),
|
{"all_words", (PyCFunction)all_words, METH_NOARGS, ""},
|
||||||
{"codepoints_for_word", (PyCFunction)cfw, METH_VARARGS, ""},
|
{"codepoints_for_word", (PyCFunction)cfw, METH_VARARGS, ""},
|
||||||
{"name_for_codepoint", (PyCFunction)nfc, METH_VARARGS, ""},
|
{"name_for_codepoint", (PyCFunction)nfc, METH_VARARGS, ""},
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
static struct PyModuleDef module = {
|
static struct PyModuleDef module = {
|
||||||
.m_base = PyModuleDef_HEAD_INIT,
|
.m_base = PyModuleDef_HEAD_INIT,
|
||||||
.m_name = "unicode_names", /* name of module */
|
.m_name = "unicode_names", /* name of module */
|
||||||
@ -108,3 +109,13 @@ PyInit_unicode_names(void) {
|
|||||||
if (m == NULL) return NULL;
|
if (m == NULL) return NULL;
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
EXPORTED
|
||||||
|
initunicode_names(void) {
|
||||||
|
PyObject *m;
|
||||||
|
m = Py_InitModule3("unicode_names", module_methods,
|
||||||
|
""
|
||||||
|
);
|
||||||
|
if (m == NULL) return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
2
kitty/emoji.h
generated
2
kitty/emoji.h
generated
@ -1,4 +1,4 @@
|
|||||||
// unicode data, built from the unicode standard on: 2018-04-24
|
// unicode data, built from the unicode standard on: 2018-05-01
|
||||||
// see gen-wcwidth.py
|
// see gen-wcwidth.py
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// unicode data, built from the unicode standard on: 2018-04-24
|
// unicode data, built from the unicode standard on: 2018-05-01
|
||||||
// see gen-wcwidth.py
|
// see gen-wcwidth.py
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
|
||||||
|
|||||||
2
kitty/wcwidth-std.h
generated
2
kitty/wcwidth-std.h
generated
@ -1,4 +1,4 @@
|
|||||||
// unicode data, built from the unicode standard on: 2018-04-24
|
// unicode data, built from the unicode standard on: 2018-05-01
|
||||||
// see gen-wcwidth.py
|
// see gen-wcwidth.py
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user