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

Fix Capture.watchStream to respect default text encoding #194

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions kernel/src/main/scala/jupyter/scala/Capture.scala
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package jupyter.scala
// Extracted from IScala, and refactored a bit

import java.io.{ Console => _, _ }
import java.nio.charset.Charset

object Capture {
private def watchStream(
Expand All @@ -13,11 +14,12 @@ object Capture {
) =
new Thread(name) {
override def run() = {
val buffer = Array.ofDim[Byte](size)
val buffer = Array.ofDim[Char](size)
val reader = new InputStreamReader(input, Charset.defaultCharset())

try {
while (true) {
val n = input read buffer
val n = reader.read(buffer, 0, size)
if (n > 0) fn(new String(buffer take n))
if (n < size) Thread.sleep(50) // little delay to accumulate output
}
Expand Down