Coverage for pyquickhelper/texthelper/diacritic_helper.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-03 02:21 +0200

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

2""" 

3@file 

4@brief Some functions about diacritics 

5""" 

6 

7import unicodedata 

8 

9 

10def remove_diacritics(input_str): 

11 """ 

12 Removes diacritics. 

13 

14 @param input_str string to clean 

15 @return cleaned string 

16 

17 Example:: 

18 

19 enguérand --> enguerand 

20 """ 

21 nkfd_form = unicodedata.normalize('NFKD', input_str) 

22 only_ascii = nkfd_form.encode('ASCII', 'ignore') 

23 return only_ascii.decode("utf8")