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 of generated XML files changed to UTF-8 #289

Open
wants to merge 1 commit into
base: sbt-0.13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/scala/org/sbtidea/IdeaProjectDescriptor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object OutputUtil {
def saveFile(file: File, node: xml.Node) {
val prettyPrint = new scala.xml.PrettyPrinter(150, 2)
val fos = new FileOutputStream(file)
val w = Channels.newWriter(fos.getChannel(), XML.encoding)
val w = Channels.newWriter(fos.getChannel(), "UTF-8")

ultimately(w.close())(
w.write(prettyPrint.format(node))
Expand Down
15 changes: 13 additions & 2 deletions src/main/scala/org/sbtidea/SaveableXml.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package org.sbtidea
import java.io.File
import sbt.Logger
import xml.Node
import java.nio.charset.UnmappableCharacterException

trait SaveableXml {
val log: Logger
Expand All @@ -19,7 +20,17 @@ trait SaveableXml {
val file = new File(path)
file.getParentFile.mkdirs()

OutputUtil.saveFile(file, content)
log.info("Created " + path)
try {
OutputUtil.saveFile(file, content)
log.info("Created " + path)
} catch {
case e: UnmappableCharacterException => {
val prettyPrint = new scala.xml.PrettyPrinter(150, 2)
log.error("Unable to encode file: " + file)
val text: String = prettyPrint.format(content)
log.error("=> content pretty printed=" + text)
log.error("=> List[Char]=" + text.toList)
}
}
}
}