[Project_owners] Editor content

Michael Buckley michael.buckley at hotmail.com
Mon Sep 11 15:44:09 EDT 2006


Thomas Schmid wrote:
>Hi,
>
>Michael Buckley wrote:
>>Thanks that is what I needed, though it put out \n\r were it should only
>>be \n  if you understand what I mean.  Easy enough to fix.  Here is what
>>my script looks like.
>>
>>
>>   var editor = document.getElementById('myEditor');
>>
>>  var oldStr =
>>editor.getEditor(editor.contentWindow).outputToString("text/plain", 0);
>>    var findStr = '\n\r';
>>    var repStr = '';
>>
>>    var srchNdx = 0;
>>    var newStr = '';
>>    while (oldStr.indexOf(findStr,srchNdx) != -1) {
>>        newStr  = 
>>oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
>>        newStr  = repStr;
>>        srchNdx = (oldStr.indexOf(findStr,srchNdx)   findStr.length   1);
>>    }
>>    newStr  = oldStr.substring(srchNdx,oldStr.length);
>>
>>newStr being the text.
>
>you can also use regex to convert \n\r into a \n:
>
>  // convert all \n\r to \n...
>  var newStr = oldStr.replace(/\n\r/g,"\n");
>
>Are you really sure, that you got a \n\r and not \r\n ?
>A \n\r would be very strange, while \r\n is normal on Windows.
>Old Macs use \r. Unix, Linux, Mac OS X and Mozilla define a newline as \n.
>
>Regards
>
>Thomas
>
>_______________________________________________
>Project_owners mailing list
>Project_owners at mozdev.org
>http://mozdev.org/mailman/listinfo/project_owners
>
We are both right, it is giving  \n\r\n.  \n\r with and extra \n thrown in.

I think some one need to file this as a bug because have you ever
noticed in Thunderbird that if you look over a message that has gone
bake a forth several times in plain text, the message ends up with large
gaps between lines.  Kind of annoying.

Thanks for the details about how each OS handles new lines, looks like I
going to have to do something for each platform.

God Bless
Micahel

_________________________________________________________________
Windows Live Spaces: share up to 500 photos per month, free 
http://spaces.live.com/



More information about the Project_owners mailing list