I have a string, for example "2013 International Truck – XZ1234" which I need to urlencode() and include in a mailto subject= in a way that will be properly decoded. I have tested this in the following way:
$encodedstring = urlencode("mailto:info@something.com?subject=2013 International Truck – XZ1234")
<a href="<?php $encodedstring ?>">Email Us</a>
The link will then look like this:
<a href="mailto:info@southlandit.com?subject=2013+International+Truck+%26%238211%3B+XZ1234">Email Us</a>
The subject then is decoded and displayed in the subject input field to look like this: (this has been tested in Gmail)
2013 International TerraStar Truck – NT2031
Is there an alternative to urlencode() or some other way to encode this string so that all characters, including dashes are properly decoded in mail clients?
Your string is being double encoded. %26%238211%3B
is the encoded form of –
, which is the encoded form of the dash. Trace your code execution to see where it is being encoded twice.