diff options
Diffstat (limited to 'pycparser/__init__.py')
-rw-r--r-- | pycparser/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pycparser/__init__.py b/pycparser/__init__.py index d82eb2d..842a81d 100644 --- a/pycparser/__init__.py +++ b/pycparser/__init__.py @@ -49,7 +49,7 @@ def preprocess_file(filename, cpp_path='cpp', cpp_args=''): def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='', - parser=None): + parser=None, encoding=None): """ Parse a C file using pycparser. filename: @@ -71,6 +71,9 @@ def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='', r'-I../utils/fake_libc_include' If several arguments are required, pass a list of strings. + encoding: + Encoding to use for the file to parse + parser: Optional parser object to be used instead of the default CParser @@ -82,7 +85,7 @@ def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='', if use_cpp: text = preprocess_file(filename, cpp_path, cpp_args) else: - with io.open(filename) as f: + with io.open(filename, encoding=encoding) as f: text = f.read() if parser is None: |