Skip to content

Commit 15a00b3

Browse files
committed
Change default encoding in XML.save to UTF-8
Was ISO-8859-1, which resulted in encoding errors at runtime if document contained non-latin1 characters. Also XML spec states that documents without xml declaration are expected to contain UTF-8 or UTF-16 - so writing in ISO-8859-1 without xml declaration (which was the default) can easily break compliant parsers.
1 parent 5f7601a commit 15a00b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

shared/src/main/scala/scala/xml/XML.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ object XML extends XMLLoader[Elem] {
6464
val preserve = "preserve"
6565
val space = "space"
6666
val lang = "lang"
67-
val encoding = "ISO-8859-1"
67+
val encoding = "UTF-8"
6868

6969
/** Returns an XMLLoader whose load* methods will use the supplied SAXParser. */
7070
def withSAXParser(p: SAXParser): XMLLoader[Elem] =
@@ -83,7 +83,7 @@ object XML extends XMLLoader[Elem] {
8383
final def save(
8484
filename: String,
8585
node: Node,
86-
enc: String = encoding,
86+
enc: String = "UTF-8",
8787
xmlDecl: Boolean = false,
8888
doctype: dtd.DocType = null): Unit =
8989
{

0 commit comments

Comments
 (0)