George Reith
George Reith

Reputation: 13476

rawurlencode not encoding white spaces

Here is a snippet of my code:

print ('href="files/'.rawurlencode($projectDesc).'/'.rawurlencode($file["FILENAME"]).'.pdf#zoom=100&view=Fit&pagemode='.$file["MODE"].'&page='.$file["PAGE"].'" class="pdfselector" target="_blank">');

the $file["FILENAME"] variable often has white-space in it, when I use plain old urlencode() it converts my white spaces to +symbols. However this is not appropriate outside the querystring so I switched to rawurlencode() which now appears to ignore white space all together.

Here is an example output of my rawurlencode():

eHealth flyer_Final

notice how it completely ignores the white space, anyone got any ideas as to why this would be happening?

Upvotes: 1

Views: 1321

Answers (1)

genesis
genesis

Reputation: 50966

Works for me

http://sandbox.phpcode.eu/g/44af2.php

<?php 
$projectDesc = "eHealth flyer_Final"; 
$file["FILENAME"] = "eHealth flyer_Final"; 
$file["MODE"] = "test"; 

print ('href="files/'.rawurlencode($projectDesc).'/'.rawurlencode($file["FILENAME"]).'.pdf#zoom=100&view=Fit&pagemode='.$file["MODE"].'&page='.$file["PAGE"].'" class="pdfselector" target="_blank">'); 

Upvotes: 1

Related Questions