Search code examples
webkitace-editor

ACE Editor Line Endings Set To Windows Format


Is there a way to set line endings to windows? Which are ^M if i'm not mistaken

I'm sending my ACE to a private API which I cannot control, this expects a format with windows line endings.

Editor = ace.edit("e"); 
ValueSentToServer = Editor.getValue(); 

Is what i am using to get the value.

When doing an ajax call to get a file source I'm seeing

As the line ending tags in WebKit console.


Solution

  • use editor.session.setNewLineMode("windows")

    but if you submit it with form chances are line endings will be converted by browser automatically. See https://github.com/ajaxorg/ace/issues/1515#issuecomment-20971401 and http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4