magic encoding