Fix ~ rule bug

Tildes are not being correctly encoded.  Fixed by reversing order in rule pair.