Created
September 25, 2019 16:43
-
-
Save msosnicki/3ee998d9854583d03d7d462311bbdbd9 to your computer and use it in GitHub Desktop.
utf8Decode bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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