Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transmitting newline character "\n"

Given the following URL (working, try it!)

https://select-test.wp3.rbsworldpay.com/wcc/purchase?instId=151711&cartId=28524&currency=GBP&amount=1401.49&testMode=100&name=Tom%20Gul&address=24%20House%20Road\nSome Place\nCounty&postcode=TR33%20999&[email protected]&country=GB

If you click on the link and go through to the payment page, the address in the address box is not displaying properly, the newline characters are displaying as text.

I've tried passing through <br />'s but no luck, anyone got any ideas? I need to get the address to display with newlines.

Commas are OK as a separator but i would much prefer being able to have newlines. Thanks for any help! A working example will be the accepted answer.

like image 688
Tom Gullen Avatar asked Oct 06 '10 10:10

Tom Gullen


People also ask

Is it n or \n for New line?

Operating systems have special characters denoting the start of a new line. For example, in Linux a new line is denoted by “\n”, also called a Line Feed. In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF.

What is a \n character?

LF (character : \n, Unicode : U+000A, ASCII : 10, hex : 0x0a): This is simply the '\n' character which we all know from our early programming days. This character is commonly known as the 'Line Feed' or 'Newline Character'.

What is \n line break?

Newline (frequently called line ending, end of line (EOL), next line (NEL) or line break) is a control character or sequence of control characters in a character encoding specification (e.g., ASCII, EBCDIC) that is used to signify the end of a line of text and the start of a new one.

What does \n do in Windows?

'\n' is the Line Feed character. Traditionally, it caused the printer to roll the paper up one line. '\r' is the Carriage Return character, which traditionally caused the printer head to move to the far left edge of the paper.


4 Answers

Try using %0A in the URL, just like you've used %20 instead of the space character.

like image 143
rhino Avatar answered Oct 12 '22 17:10

rhino


Try to replace the \n with %0A just like you have spaces replaced with %20.

like image 23
eumiro Avatar answered Oct 12 '22 18:10

eumiro


Use %0A (URL encoding) instead of \n (C encoding).

like image 22
DarkDust Avatar answered Oct 12 '22 19:10

DarkDust


late to the party, but if anyone comes across this, javascript has a encodeURI method

like image 41
marisbest2 Avatar answered Oct 12 '22 18:10

marisbest2