0

i have this text:

this is a sample
text

Apparently, after "sample" there is a Line feed character (ENTER). How can i encode JUST those characters and not the whole string. When i use encodeURI the whole string gets encoded What i want to do is to get a string like "this is a sample%0Atext" Thanks

Nicos
  • 303
  • 2
  • 19

1 Answers1

0

So double url encoding - where the API requires raw input of %250A for a \n ?

str = str.replace(/[\r\n]/g, function(m) { return escape(m); });
Alex K.
  • 171,639
  • 30
  • 264
  • 288