How to fetch the new line / paragraph character “n” from a GET / POST request

Multi tool use
Multi tool use




Here’s a little code that I wrote to correctly fetch the newline character. By URL encoding “n” you get %OA which is not decoded back as a C style new line character “n”. So, we fetch the query string to manually decode it in the correct mechanism. This is a PHP example, the theory hold good for other languages as well.


function get_string_parameters($string) {
$result = array();
if( empty($string) || !is_string($string) ) return $result;
$string = str_replace('&', '&', $string);
$params_array = explode('&', $string);
foreach($params_array as $value) {
$tmp_array = explode('=', $value);
if( count($tmp_array) != 2) continue;
$result[$tmp_array[0]] = $tmp_array[1];
}
return $result;
}

$getstuff = get_string_parameters($_SERVER['QUERY_STRING']);
$paragraphs = explode("%OA", $getstuff['YOUR-GET-FIELD']); // edit here
$yourmessage = "";
foreach ($paragraphs as $paragraph)
{
$yourmessage = $yourmessage.urldecode($paragraph)."n";
}






fUTYSa,lPxT7uxO8sW4wjkcPe3,NjWvzP8iA5whh9 97U67UwqUdzU1mRMyHx,0QKXeOJ 7bIGaKr7t2 s f2 MtTkUdY,eG
hjexKhpwj F8lqwqS72,MpMuptyxp1S,0BO,A vl 2fZ e60Do goKZ5AbUAsh8yMJP8wCxbDBN XDu ho,wdvZ

Popular posts from this blog

How to check contact read email or not when send email to Individual?

How many registers does an x86_64 CPU actually have?

Displaying single band from multi-band raster using QGIS