From b0c0e57a6bf5fa754e7a18bf54bf79e2580fdf18 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 1 Aug 2013 09:40:57 +1000 Subject: Bug [#1506]. In some locales Visual C++ fails with UTF-8 in string literals. Fixed by using hex escapes for non-ASCII. --- scripts/GenerateCaseConvert.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/GenerateCaseConvert.py') diff --git a/scripts/GenerateCaseConvert.py b/scripts/GenerateCaseConvert.py index 841cdcc51..bcf49236f 100644 --- a/scripts/GenerateCaseConvert.py +++ b/scripts/GenerateCaseConvert.py @@ -101,6 +101,9 @@ def groupRanges(symmetrics): return rangeGroups, nonRanges +def escape(s): + return "".join((chr(c) if chr(c) in string.ascii_letters else "\\x%x" % c) for c in s.encode('utf-8')) + def updateCaseConvert(): symmetrics, complexes = conversionSets() @@ -114,7 +117,7 @@ def updateCaseConvert(): print(len(symmetrics), "symmetric") - complexLines = ['"%s|%s|%s|%s|"' % x for x in complexes] + complexLines = ['"%s|%s|%s|%s|"' % tuple(escape(t) for t in x) for x in complexes] print(len(complexLines), "complex") Regenerate("../src/CaseConvert.cxx", "//", rangeLines, nonRangeLines, complexLines) -- cgit v1.2.3