Would probably be best to use some kind of container class that tags an output stream so that it'll write the appropriate encoded text to the streams.