this isnt directly related to output excaping. however the output escaping relies on it. should this maybe be moved to somewhere shared?