format in TCL in not working correctly,I am trying to format some text and writing them in a file and then sending that file as a mail to user. I am seeing that format is correct in Linux but when mail comes to user then format is not proper.
code-
puts [format {%-50s%-170s%-50s%-50s} "Test_Id" "Test_Description" "Test_Ran_Count" "Test_Result"]
puts [format {%-50s%-170s%-50s%-50s} $test_id1 "$mail_desc1" $loop_count $test_result]
puts [format {%-50s%-170s%-50s%-50s} $test_id "$mail_desc" $loop_count $test_result]
output-
Test_Id           Test_Description            Test_Ran_Count                Test_Result                                       
test_id_1         To execute - test_id_1            10                         PASS
test_id_2         To execute - test_id_2            10                         PASS  
here if test_id_2 is big then entire format is shifting,as per format behavior if test_id is less then 50 char then it should not shift other column as I am giving %-50s for test_id.
                        
Format fields (which Tcl borrows from C's
sprintf()with very few changes) are a bit tricky. When you use%50s(or%-50s— the-just affects alignment) you are setting a minimum field width. To set a maximum field width, you might use%.50s. Or, more likely in your case, you'll set minimum, maximum and alignment:%-50.50s.Demonstrating with some narrower fields and simple strings of different lengths:
Which produces this output:
As you can see, left aligned, completely fixed width requires giving
%-N.Ns(for someN).