mirror of
https://0xacab.org/anarsec/anarsec.guide.git
synced 2025-06-07 22:32:55 -04:00
python and typst script
This commit is contained in:
parent
da5f497ec1
commit
be05046783
19 changed files with 2223 additions and 0 deletions
21
layout/python/text_unidecode/__init__.py
Normal file
21
layout/python/text_unidecode/__init__.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
import os
|
||||
import pkgutil
|
||||
|
||||
_replaces = pkgutil.get_data(__name__, 'data.bin').decode('utf8').split('\x00')
|
||||
|
||||
def unidecode(txt):
|
||||
chars = []
|
||||
for ch in txt:
|
||||
codepoint = ord(ch)
|
||||
|
||||
if not codepoint:
|
||||
chars.append('\x00')
|
||||
continue
|
||||
|
||||
try:
|
||||
chars.append(_replaces[codepoint-1])
|
||||
except IndexError:
|
||||
pass
|
||||
return "".join(chars)
|
Loading…
Add table
Add a link
Reference in a new issue