@unknownuser said:
I personally see no productivity or functionality gains from bothering with each platforms newline patterns, unless you just want to.
This isn't the file I want given the input textarea:
[image: GfrM_two.jpg]
You have to convert crlf to newline because Ruby converts newline to crlf as it writes the file on a PC. Ugh.
# ta_sep.rb
require 'sketchup'
html="
<html> <body>
<textarea id='ta'>one
two</textarea>
<script>
onload = function() { location = 'skp;go'; }
</script>
</body> </html>"
wd = UI;;WebDialog.new( "Test", true, "test", 400, 300, 100, 100, true )
wd.set_html( html )
wd.add_action_callback( "go" ) do | dlg, msg |
val = wd.get_element_value( 'ta' )
# val.gsub!( /\r\n/, "\n" )
pn = UI.savepanel(
"Save As ...", File.dirname(__FILE__), 't.txt' )
file = File.new( pn, 'w' )
file.puts( val )
file.close()
end
wd.show()
I think this is correct cross-platform code if you uncomment the gsub!(). For this I be thanking you and Notepad++ (View/Show Symbol/Show All Characters).
Ruby's lovely ability to handle everything with newlines, platform-independently, does not extend to text read from a browser's textarea widgets.