XML Marshal Line Endings CRLF
up vote
0
down vote
favorite
How can I tell xml.Marshal or xml.MarshalIndent to terminate lines in Windows CRLF line endings rather than the LF that it's producing now?
Note: I tried running strings.Replace(s, "n", "rn", -1)
and strings.Replace(s, ">n", ">rn", -1)
to transform after the fact but that caused more troubles than it solved. A blanket string replacement won't work.
go
|
show 4 more comments
up vote
0
down vote
favorite
How can I tell xml.Marshal or xml.MarshalIndent to terminate lines in Windows CRLF line endings rather than the LF that it's producing now?
Note: I tried running strings.Replace(s, "n", "rn", -1)
and strings.Replace(s, ">n", ">rn", -1)
to transform after the fact but that caused more troubles than it solved. A blanket string replacement won't work.
go
I doubt you can. And you should not as CRLF ist wrong anyway.
– Volker
Nov 8 at 19:09
>> And you should not as CRLF ist wrong anyway. That's definitely an opinion and I'm glad you're able to do this but the requirements of the task won't allow it. I really did ask the question I was hoping to have answered.
– Will Rubin
Nov 8 at 19:22
Not possible with the encoding/xml package due to the way it emits the newlines on github.com/golang/go/blob/master/src/encoding/xml/…
– Michael MacDonald
Nov 8 at 19:24
Bummer! (But thanks for the definitive link @michael-macdonald.) I hate it when Go doesn't present well because of an arbitrary decision. "Sorry guys, Go's not the right choice for this after all. The designers decided CRLF wasn't something they wanted you to be able to use here."
– Will Rubin
Nov 8 at 20:02
1
play.golang.org/p/SNYZla8n5jx
– dave
Nov 8 at 20:40
|
show 4 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
How can I tell xml.Marshal or xml.MarshalIndent to terminate lines in Windows CRLF line endings rather than the LF that it's producing now?
Note: I tried running strings.Replace(s, "n", "rn", -1)
and strings.Replace(s, ">n", ">rn", -1)
to transform after the fact but that caused more troubles than it solved. A blanket string replacement won't work.
go
How can I tell xml.Marshal or xml.MarshalIndent to terminate lines in Windows CRLF line endings rather than the LF that it's producing now?
Note: I tried running strings.Replace(s, "n", "rn", -1)
and strings.Replace(s, ">n", ">rn", -1)
to transform after the fact but that caused more troubles than it solved. A blanket string replacement won't work.
go
go
asked Nov 8 at 19:04
Will Rubin
537
537
I doubt you can. And you should not as CRLF ist wrong anyway.
– Volker
Nov 8 at 19:09
>> And you should not as CRLF ist wrong anyway. That's definitely an opinion and I'm glad you're able to do this but the requirements of the task won't allow it. I really did ask the question I was hoping to have answered.
– Will Rubin
Nov 8 at 19:22
Not possible with the encoding/xml package due to the way it emits the newlines on github.com/golang/go/blob/master/src/encoding/xml/…
– Michael MacDonald
Nov 8 at 19:24
Bummer! (But thanks for the definitive link @michael-macdonald.) I hate it when Go doesn't present well because of an arbitrary decision. "Sorry guys, Go's not the right choice for this after all. The designers decided CRLF wasn't something they wanted you to be able to use here."
– Will Rubin
Nov 8 at 20:02
1
play.golang.org/p/SNYZla8n5jx
– dave
Nov 8 at 20:40
|
show 4 more comments
I doubt you can. And you should not as CRLF ist wrong anyway.
– Volker
Nov 8 at 19:09
>> And you should not as CRLF ist wrong anyway. That's definitely an opinion and I'm glad you're able to do this but the requirements of the task won't allow it. I really did ask the question I was hoping to have answered.
– Will Rubin
Nov 8 at 19:22
Not possible with the encoding/xml package due to the way it emits the newlines on github.com/golang/go/blob/master/src/encoding/xml/…
– Michael MacDonald
Nov 8 at 19:24
Bummer! (But thanks for the definitive link @michael-macdonald.) I hate it when Go doesn't present well because of an arbitrary decision. "Sorry guys, Go's not the right choice for this after all. The designers decided CRLF wasn't something they wanted you to be able to use here."
– Will Rubin
Nov 8 at 20:02
1
play.golang.org/p/SNYZla8n5jx
– dave
Nov 8 at 20:40
I doubt you can. And you should not as CRLF ist wrong anyway.
– Volker
Nov 8 at 19:09
I doubt you can. And you should not as CRLF ist wrong anyway.
– Volker
Nov 8 at 19:09
>> And you should not as CRLF ist wrong anyway. That's definitely an opinion and I'm glad you're able to do this but the requirements of the task won't allow it. I really did ask the question I was hoping to have answered.
– Will Rubin
Nov 8 at 19:22
>> And you should not as CRLF ist wrong anyway. That's definitely an opinion and I'm glad you're able to do this but the requirements of the task won't allow it. I really did ask the question I was hoping to have answered.
– Will Rubin
Nov 8 at 19:22
Not possible with the encoding/xml package due to the way it emits the newlines on github.com/golang/go/blob/master/src/encoding/xml/…
– Michael MacDonald
Nov 8 at 19:24
Not possible with the encoding/xml package due to the way it emits the newlines on github.com/golang/go/blob/master/src/encoding/xml/…
– Michael MacDonald
Nov 8 at 19:24
Bummer! (But thanks for the definitive link @michael-macdonald.) I hate it when Go doesn't present well because of an arbitrary decision. "Sorry guys, Go's not the right choice for this after all. The designers decided CRLF wasn't something they wanted you to be able to use here."
– Will Rubin
Nov 8 at 20:02
Bummer! (But thanks for the definitive link @michael-macdonald.) I hate it when Go doesn't present well because of an arbitrary decision. "Sorry guys, Go's not the right choice for this after all. The designers decided CRLF wasn't something they wanted you to be able to use here."
– Will Rubin
Nov 8 at 20:02
1
1
play.golang.org/p/SNYZla8n5jx
– dave
Nov 8 at 20:40
play.golang.org/p/SNYZla8n5jx
– dave
Nov 8 at 20:40
|
show 4 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214512%2fxml-marshal-line-endings-crlf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I doubt you can. And you should not as CRLF ist wrong anyway.
– Volker
Nov 8 at 19:09
>> And you should not as CRLF ist wrong anyway. That's definitely an opinion and I'm glad you're able to do this but the requirements of the task won't allow it. I really did ask the question I was hoping to have answered.
– Will Rubin
Nov 8 at 19:22
Not possible with the encoding/xml package due to the way it emits the newlines on github.com/golang/go/blob/master/src/encoding/xml/…
– Michael MacDonald
Nov 8 at 19:24
Bummer! (But thanks for the definitive link @michael-macdonald.) I hate it when Go doesn't present well because of an arbitrary decision. "Sorry guys, Go's not the right choice for this after all. The designers decided CRLF wasn't something they wanted you to be able to use here."
– Will Rubin
Nov 8 at 20:02
1
play.golang.org/p/SNYZla8n5jx
– dave
Nov 8 at 20:40