• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Preserving newlines in Textarea

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP contains textarea that can display data with various types of newlines (CR, LF, CR/LF). All various types of newline display fine, the problem is when the data is edited and the form posted.

The only situation where there's an issue is when message data contains '0A' (LF) by itself. On posting the form, these are converted to 'ODOA' (CR/LF). I only see this in Internet Explorer, it does not seem to happen in Firefox.

I've tried to no avail:
* grabbing the value/innerText/innerHTML values
* cloning the textarea element and grabbing that clone's innerText
* setting style=white-space:pre;
* changing the Page/Browser encoding values

Anyone know of way to preserve original newline bytes in IE as I described?

thanks in advance,
Tom
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clarification: the conversion does not happen on post, that just happened to be when I noticed it. Actually, there's a difference in IE vs. Firefox for displaying '\n'. Firefox's textarea contains only '\n' (0a), while IE will expand it to '\r\n' (0d0a).
 
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not believe that you will be able to change IE's behavior. You'll just have to detect and deal with the differences.
 
Tom Katz
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks - that's what I was afraid of.
 
Do you pee on your compost? Does this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic