Divyesh Patel <
divyes...@gmail.com> wrote:
Please edit out the extra blank lines that Google Groups adds to your
posting before you submit your reply (note how the formatting is above).
You are being very unclear in exactly what it is you want.
When you say "I want to insert a line feed character" that means you want a
single byte to be inserted, and that byte to have the value 10 (decimal).
Your reply above indicates that when you use "\n" you get "a single byte ...
inserted, and that byte ... has the value 10 (decimal)". Which means you
are currently receiving just exactly what you are asking for.
But the end of your sentence: "instead of putting " implies that you
want something other than "a single byte with the value 10 (decimal)" to be
inserted.
It implies that what you actually want to ask is:
"How to I get newlines inserted into an XML document to actually be encoded
as an XML character escape?"
Which is a completely different question.
Likely the reason why \n is not encoded is that a byte with a value of 10
(decimal) is a legal (and recommended by the standard) way to insert
newlines into an XML documents. So that means if you really do want the
newline bytes encoded as xml character escapes, you will have to do that
encoding yourself.
One way to do it is to filter your whole xml document through [string map]
when you save/send it somewhere, and ask [string map] to change all the
"bytes with value 10" into "strings with value ' '".
I.e., like so:
set encoded_xml [ string map [ list \n " " ] $raw_xml ]