Skip to content

Commit 5b4062c

Browse files
committed
make sure the bibtex author string is ascii
1 parent 804040b commit 5b4062c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Documentation/scripts/generate_how_to_cite.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import re
55
import codecs
66
from sys import argv
7+
from sys import stderr
78

89
### Constants ###
910

@@ -139,7 +140,13 @@ def protect_upper_case(title):
139140
return title.replace("dD","{dD}").replace("2D","{2D}").replace("3D","{3D}").replace("CGAL","{CGAL}").replace("Qt","{Qt}").replace("Boost","{Boost}")
140141

141142
def protect_accentuated_letters(authors):
142-
return authors.replace(u"é",r"{\'e}").replace(u"ä",r"{\"a}").replace(u"ö",r"{\"o}").replace(u"ñ",r"{\~n}").replace(u"ã",r"{\~a}").replace(u"ë",r"{\"e}").replace("%","")
143+
res=authors.replace(u"é",r"{\'e}").replace(u"ä",r"{\"a}").replace(u"ö",r"{\"o}").replace(u"ñ",r"{\~n}").replace(u"ã",r"{\~a}").replace(u"ë",r"{\"e}").replace("%","")
144+
try:
145+
res.decode('ascii')
146+
except UnicodeEncodeError:
147+
stderr.write("WARNING: a non ascii character has been found in author string for bibtex (probably a non-handled accentuated letter)."
148+
"Check the new package added and update the function protect_accentuated_letters in Documentation/scripts/generate_how_to_cite.py\n\n")
149+
return res
143150

144151
### Start of the main function ###
145152

0 commit comments

Comments
 (0)