from pathlib import Path


def _read_primitive(path):
    """
    We read using the UTF-8 instead of the default encoding since notebooks are
    always stored in UTF-8.

    We can see this in nbformat, which always reads as UTF-8:
    https://github.com/jupyter/nbformat/blob/df63593b64a15ee1c37b522973c39e8674f93c5b/nbformat/__init__.py#L125

    Scripts are a different story since they may have other encodings, however,
    modern editors have UTF-8 as default (example: VSCode
    https://docs.microsoft.com/en-us/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding?view=powershell-7.2#configuring-vs-code)
    so it's safer to use UTF-8 than the default encoding.

    jupytext already does this:
    https://github.com/mwouts/jupytext/issues/896
    """
    return Path(path).read_text(encoding='utf-8')