Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/text_unidecode-1.3-py3.11.egg/text_unidecode/__init__.py: 29%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

17 statements  

1# -*- coding: utf-8 -*- 

2from __future__ import absolute_import, unicode_literals 

3import os 

4import pkgutil 

5 

6_replaces = pkgutil.get_data(__name__, 'data.bin').decode('utf8').split('\x00') 

7 

8def unidecode(txt): 

9 chars = [] 

10 for ch in txt: 

11 codepoint = ord(ch) 

12 

13 if not codepoint: 

14 chars.append('\x00') 

15 continue 

16 

17 try: 

18 chars.append(_replaces[codepoint-1]) 

19 except IndexError: 

20 pass 

21 return "".join(chars)