Some SIP forwarders and clients are very limited and/or broken to only allow ASCII 0-9 in the SIP URI username. So, it is useful to have an encoding for all text into only ASCII 0-9 in as few resulting charatcters as possible in the average case.

Full ASCII goes to 127, so it takes three digits to encode each point. However if we subtract 31 to remove the nonprinting space at the front of ASCII then we get all points that fit within two digits.

The encoding:

bytes = text encoded in utf8

if all (byte - 30 < 99) then concat of each byte { base 10 encode of (byte - 30), two digits each } else "00" + concat of each byte { base 10 encode, three digits each } end