Request: IOSink that constructs a StringBuffer #9051
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
core-n
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
See https://groups.google.com/a/dartlang.org/forum/?fromgroups=#!search/BREAKING$20CHANGE:$20IOSink$20interface$20has$20changed/misc/LWIklgvGX8U/L1-PnNhdVpMJ
Request to bridge StringSink and IOSink.
Soren writes:
I must disagree here. A StringSink is something which can receive strings e.g. the StringBuffer. An IOSink is simething which can receive data to be send on an IO channel. The only thing that can be written to an IO channel is bytes. As an IO channel needs bytes then whenever strings are written to an IOSink an encoding is needed for transferring the sequence of code points into bytes. So an IOSink can only be a StringSink if there is an encoding.
For files the openWrite method takes an encoding and the IOSink has a property for changing the encoding in this case. For HTTP the encoding is taken from the "charset" parameter from the "Content-Type" header.
In general you cannot encapsulate HttpResponse to direct the output to a StringBuffer as HTTP is a binary protocol transmitting bytes. In some cases these bytes have a string representation given an encoding.
Tom writes:
Sure, you interpret it this way, and I'm OK with it. However, what I am looking for is an easy way to encapsulate StringBuffer to IOSink. It is something like StringWriter in Java.
The text was updated successfully, but these errors were encountered: