Fix ~ rule bug

Tildes are not being correctly encoded.