Skip to content

Instantly share code, notes, and snippets.

@msosnicki
Created September 25, 2019 16:43
Show Gist options
  • Save msosnicki/3ee998d9854583d03d7d462311bbdbd9 to your computer and use it in GitHub Desktop.
Save msosnicki/3ee998d9854583d03d7d462311bbdbd9 to your computer and use it in GitHub Desktop.
utf8Decode bug
package zio.stream
import zio._
object Utf8Bug extends App {
val char = "\u00BB"
val string = List.fill(10)(char).mkString
val bytes = string.getBytes("UTF-8")
override def run(args: List[String]): ZIO[Environment, Nothing, Int] =
app.fold(_ => 1, _ => 0)
val app = for {
res1 <- Stream
.fromIterable(bytes)
.transduce(Sink.utf8Decode(19))
.runCollect
.map(_.mkString)
res2 <- Stream
.fromIterable(bytes)
.transduce(Sink.utf8Decode(20))
.runCollect
.map(_.mkString)
} yield assert(res1 == res2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment