import struct


def add(text: str) -> str:
    """
    Add surrogate pairs to characters in the text. This makes the indices match how most platforms
    calculate string length when formatting texts using offset-based entities.

    Args:
        text: The text to add surrogate pairs to.

    Returns:
        The text with surrogate pairs.
    """
    return "".join(
        "".join(chr(y) for y in struct.unpack("<HH", x.encode("utf-16le")))
        if (0x10000 <= ord(x) <= 0x10FFFF)
        else x
        for x in text
    )