Conversion to or from weighted codes