Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
142
rated 0 times [  148] [ 6]  / answers: 1 / hits: 16691  / 8 Years ago, sun, july 31, 2016, 12:00:00

See fiddle: if you press Enter in the textarea on a recent Mac, the newline character appears to be represented by r, which would be in direct contrast to the answers to this, this and this question and to Wikipedia. To summarise these links:




  • r represents a line break on old Macs (OS 9 and before)

  • n represents a line break on UNIX systems (OS X, Linux)

  • rn represents a line break on Windows.



When I press Enter in the JSFiddle, I get the following result (OS X 10.11.6):



textarea: r

span: n


This behaviour took a long time to figure out and seems illogical. What could be the underlying rationale?


More From » html

 Answers
65

I believe you're confusing two things:




  1. What character code does pressing the enter key yield?

  2. What line ending is used on which platforms?



As far as I know, the answer to #1 is 13 (ASCII carriage return, r) for all platforms.



Do you have a platform where this is not what you're seeing?


[#61197] Thursday, July 28, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
feliciarainak

Total Points: 104
Total Questions: 91
Total Answers: 83

Location: Greenland
Member since Thu, Oct 27, 2022
2 Years ago
;