diff --git a/montepy/input_parser/input_reader.py b/montepy/input_parser/input_reader.py index 12baa629..0be4ae07 100644 --- a/montepy/input_parser/input_reader.py +++ b/montepy/input_parser/input_reader.py @@ -32,5 +32,5 @@ def read_input(input_file, mcnp_version=DEFAULT_VERSION, encoding="ascii"): """ problem = mcnp_problem.MCNP_Problem(input_file) problem.mcnp_version = mcnp_version - problem.parse_input() + problem.parse_input(encoding=encoding) return problem diff --git a/montepy/input_parser/input_syntax_reader.py b/montepy/input_parser/input_syntax_reader.py index 540164a0..290d93d6 100644 --- a/montepy/input_parser/input_syntax_reader.py +++ b/montepy/input_parser/input_syntax_reader.py @@ -15,7 +15,7 @@ reading_queue = [] -def read_input_syntax(input_file, mcnp_version=DEFAULT_VERSION): +def read_input_syntax(input_file, mcnp_version=DEFAULT_VERSION, encoding="ascii"): """ Creates a generator function to return a new MCNP input for every new one that is encountered. @@ -25,11 +25,20 @@ def read_input_syntax(input_file, mcnp_version=DEFAULT_VERSION): The version must be a three component tuple e.g., (6, 2, 0) and (5, 1, 60). + .. Note:: + For different encoding schemes see the available list + `here `_. + + CP1252 is commonly referred to as "extended-ASCII". + You may have success with this encoding for working with special characters. + :param input_file: the path to the input file to be read :type input_file: MCNP_InputFile :param mcnp_version: The version of MCNP that the input is intended for. :type mcnp_version: tuple + :param encoding: The encoding scheme to use. + :type encoding: str :returns: a generator of MCNP_Object objects :rtype: generator """ diff --git a/montepy/mcnp_problem.py b/montepy/mcnp_problem.py index 7e4d8f3e..802b8d5d 100644 --- a/montepy/mcnp_problem.py +++ b/montepy/mcnp_problem.py @@ -232,10 +232,19 @@ def transforms(self): """ return self._transforms - def parse_input(self, check_input=False): + def parse_input(self, check_input=False, encoding="ascii"): """ Semantically parses the MCNP file provided to the constructor. + .. Note:: + For different encoding schemes see the available list + `here `_. + + CP1252 is commonly referred to as "extended-ASCII". + You may have success with this encoding for working with special characters. + + :param encoding: The encoding scheme to use. + :type encoding: str :param check_input: If true, will try to find all errors with input and collect them as warnings to log. :type check_input: bool """