Understanding domain-wall encoding theoretically and experimentally