We have various bits of code that do this in other places (I think there are a few in HTML live development). I wonder if we should just go ahead and add a PosUtils class.