Why would one environment use "+" instead of "%20" for spaces when using url_encode filter? I just uploaded some templates to the server and discovered that some of my url encoded strings are being output with a "+" for spaces instead of the "%20" that is desired. It is fine in my local environment. Any ideas?

According to the twig encode_url documentation url_encode now uses php's rawurlencode by default:


  Internally, Twig uses the PHP urlencode (or rawurlencode if you pass true as the first parameter) or the http_build_query function. Note that as of Twig 1.16.0, urlencode always uses rawurlencode (the raw argument was removed.)


I have also tried passing 'true' as the first parameter just in case. No luck.
It looks like the twig url_encode filter uses the php function http_build_query if parameters are passed to it as an array. i.e. {'key':'value', 'key':'value'}|url_encode. Otherwise it uses rawurlencode.

http_build_query was modified in php 5.4 to include a new property enc_type, that allowed you to specify that it use PHP_QUERY_RFC3986encoding (which is also what rawurlencode uses).

The url_encode filter is defined in craft/app/vendor/twig/twig/lib/Twig/Extension/Core.php on line 596, and contains a clause to make it backwards compatible with php 5.3, but you obviously will loose the encoding type. 

Options are: upgrade php to 5.4+; do not pass params as an array to the url_encode filter; or do a string replace on the encoded string.