Conversion to or from unit-distance codes