diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/clang-tools-extra/clang-tidy/add_new_check.py @@ -11,10 +11,16 @@ from __future__ import print_function import argparse +import io import os import re import sys +# The documentation files are using UTF-8, however on Windows the default +# encoding might be different (e.g. CP-1252). Force UTF-8 for all files. +def open(*args, **kwargs): + kwargs.setdefault("encoding", "utf8") + return io.open(*args, **kwargs) # Adapts the module's CMakelist file. Returns 'True' if it could add a new # entry and 'False' if the entry already existed. diff --git a/clang-tools-extra/clang-tidy/rename_check.py b/clang-tools-extra/clang-tidy/rename_check.py --- a/clang-tools-extra/clang-tidy/rename_check.py +++ b/clang-tools-extra/clang-tidy/rename_check.py @@ -10,9 +10,15 @@ import argparse import glob +import io import os import re +# The documentation files are using UTF-8, however on Windows the default +# encoding might be different (e.g. CP-1252). Force UTF-8 for all files. +def open(*args, **kwargs): + kwargs.setdefault("encoding", "utf8") + return io.open(*args, **kwargs) def replaceInFileRegex(fileName, sFrom, sTo): if sFrom == sTo: