function escapeControlCharacters(text) {
	return text.replace(
		/[\u0000-\u001F\u007F-\u009F]/gu, // eslint-disable-line no-control-regex -- intentionally including control characters
		c => `\\x${c.codePointAt(0).toString(16).padStart(2, "0")}`,
	);
}
Replaces raw control characters with the `\xXX` form.
@param {string} text The text to process.
@returns {string} `text` with escaped control characters.