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

Use UTF-8 charset when saving configs #404

Merged
merged 2 commits into from
Aug 2, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions core/src/main/scala/pureconfig/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
/**
* @author Mario Pastorelli
*/
import java.io.{ OutputStream, PrintStream }
import java.io.{ OutputStream, OutputStreamWriter }
import java.nio.charset.StandardCharsets.UTF_8
import java.nio.file.{ Files, Path }

import scala.reflect.ClassTag
Expand Down Expand Up @@ -255,9 +256,10 @@ package object pureconfig {
* @param outputStream The stream in which the configuration should be written
*/
def saveConfigToStream[Config](conf: Config, outputStream: OutputStream)(implicit writer: Derivation[ConfigWriter[Config]]): Unit = {
val printOutputStream = new PrintStream(outputStream)
// HOCON requires UTF-8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you support this claim by adding a link to https://github.com/lightbend/config/blob/master/HOCON.md#unchanged-from-json on this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

val printOutputStream = new OutputStreamWriter(outputStream, UTF_8)
val rawConf = writer.value.to(conf)
printOutputStream.print(rawConf.render())
printOutputStream.write(rawConf.render())
printOutputStream.close()
}

Expand Down