Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: add an option to marshal line breaks and tabs literally #8166

Closed
gopherbot opened this issue Jun 7, 2014 · 2 comments
Closed

encoding/xml: add an option to marshal line breaks and tabs literally #8166

gopherbot opened this issue Jun 7, 2014 · 2 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 7, 2014

by opennota:

(*Encoder).Encode and Marshal marshal line breaks as #xA; and tabs as #x9;
http://play.golang.org/p/elBX-TVXBL

It would be nice to have an option to marshal them (except in attributes) literally,
like so, for example:

encoder := xml.NewEncoder(...)
encoder.Literal = true
err := encoder.Encode(...)

// Output:
// <Foo>1
// 2
// 3</Foo>
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 9, 2014

Comment 1:

I think we would need a compelling reason to add such a feature, something more than it
would be nice.  It should be possible to do this in the program by having the XML code
write to a Writer that translates the byte sequences where appropriate.

Status changed to WontFix.

@gopherbot

This comment has been minimized.

Copy link
Author

@gopherbot gopherbot commented Jun 10, 2014

Comment 2 by opennota:

> It should be possible to do this in the program by having the XML code write to a
Writer that translates the byte sequences where appropriate.
Well, here it is. Sometimes you want your XML to be human readable, and encoding ", ',
\\, \n and \t as entities effectively prevents that.
Also, I don't see any reason at all why they should be encoded, except in attribute
values. Perhaps I should file another issue, titled "do not encode anything that needs
not to be encoded".
> It should be possible to do this in the program by having the XML code write to a
Writer that translates the byte sequences where appropriate.
There is a simpler and more efficient way - to fork the code and amend it. I don't want
to go for it.
@gopherbot gopherbot added the wontfix label Jun 10, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.