Using TolerantText as a BodyParser returns output from first Unicode

Inputs to my server can be a Unicode Text. The Default Body Parser does not help me as it always uses US-ASCII.

So, I thought of using TolerantText. Because, it’ll first try US-ASCII and fallback to UTF-8.

As in here, playframework/BodyParsers.scala at master · playframework/playframework · GitHub

It falls back to UTF-8 as expected.

But, once the BodyParser completes, I am not getting the entire input as output.

I am getting from the location where an Unicode character starts.

e.g.,

Input 1:
Waldenström’s
Waldenström’s

Output 2:
öm’s
Waldenström’s

Input 2:
Walöm’sdenström’s

Output 2:
öm’sdenström’s

But, if I see scala.io.Source.fromBytes(byteBuffer.array(), “UTF-8”).mkString() at playframework/BodyParsers.scala at master · playframework/playframework · GitHub, I am seeing a proper output.