Skip to content

Commit e15ce87

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 ddc4bb0 commit e15ce87

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object XML extends XMLLoader[Elem] {
6363
val preserve = "preserve"
6464
val space = "space"
6565
val lang = "lang"
66-
val encoding = "ISO-8859-1"
66+
val encoding = "UTF-8"
6767

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

0 commit comments

Comments
 (0)