# Why Base64 ends with a newline? (\n)

Why everything converted to Base64 has a newline at the end? It isn't one of base characters, is it?

Style[
b64 = ExportString["some pig", "Base64"],
ShowStringCharacters -> True
]

"c29tZSBwaWc=\n"


Moreover, it seems that it doesn't matter if you drop it or not:

ImportString[#, "Base64"] & /@ {b64, StringDrop[b64, -1]}

{"some pig", "some pig"}


But it may matter in general.

Related chat discussion.

Using SO js example. Try in console

> btoa("some pig")

< "c29tZSBwaWc="

• Style[b64 = ExportString["some pig", "UUE"], ShowStringCharacters -> True] also does add some extra \n. – Karsten 7. Nov 26 '15 at 9:47
• Maybe it's an Encoding Formats thing. Did you check the official Base64 standard recommendations? – Karsten 7. Nov 26 '15 at 10:27
• This silly image shows an annoyance that maybe was intended to be avoided, but it is probably irrelevant :P. – Jacob Akkerboom Nov 26 '15 at 11:20
• From wiki: "most implementations use a CR/LF newline pair to delimit encoded lines" – Jacob Akkerboom Nov 26 '15 at 11:47
• I think that short string is to be interpreted as the last encoded line. It may be convenient to be able to assume that all lines are delimited by newlines. – Michael E2 Nov 26 '15 at 13:52