These are chat archives for nrinaudo/kantan.csv

Dec 2016
Eugene Apollonsky
Dec 12 2016 16:47
hi! I'd like to encode resulting string to another encoding (cp1251). how can I do it? Probably, I should redefine CsvWriter[StringWriter]?
Something like that:
  implicit def windowsEncodingStringWriter: CsvWriter[StringWriter] =
    CsvWriter[StringWriter].contramap(f => new OutputStreamWriter(f, Charset.forName("cp1251")))
But it is ambiguous reference, of course
Nicolas Rinaudo
Dec 12 2016 22:12
@chessman did you try declaring an implicit in scope?
I don't think the encoding should be baked in at the writer level - at least, that's not how kantan.csv is designed. You want to do so at the CsvSink level
Nicolas Rinaudo
Dec 12 2016 22:18
let's say you want to write your CSV to a If you go down the rabbit hole, this'll reach kantan.codecs.resource.Resource#writerFromStream, which takes any resource of OutputStream and turns it into a resource of Writer, provided an implicit is in scope
the problem with is that there's always one in scope: the system's default. This is a mess, since it makes your code's behaviour vary from one system to the other, but that's how things currently stand
so if you want to write to your using a non-default encoding, you need something like implicit val cp1241 = new Codec(Charset.forName("cp1251"))
let me know if this does not solve your problem - if it does not, you probably found a bug