Class Netconversion.conversion_pipe

This pipeline class (see Netchannels for more information) can be used * to recode a netchannel while reading or writing. The argument in_enc * is the input encoding, and out_enc is the output encoding. * * The channel must consist of a whole number of characters. If it * ends with an incomplete multi-byte character, however, this is * detected, and the exception Malformed_code will be raised. * This exception is also raised for other encoding errors in the * channel data. * * Example. Convert ISO-8859-1 to UTF-8 while writing to the file * "output.txt": * *

*    let ch = new output_channel (open_out "output.txt") in
*    let encoder = 
*      new conversion_pipe ~in_enc:`Enc_iso88591 ~out_enc:`Enc_utf8 () in
*    let ch' = new output_filter encoder ch in
*    ... (* write to ch' *)
*    ch' # close_out();
*    ch  # close_out();  (* you must close both channels! *)
* 

* * If you write as UTF-16, don't forget to output the byte order * mark yourself, as the channel does not do this. * * Example. Convert UTF-16 to UTF-8 while reading from the file * "input.txt": * *

*    let ch = new input_channel (open_in "input.txt") in
*    let encoder = 
*      new conversion_pipe ~in_enc:`Enc_utf16 ~out_enc:`Enc_utf8 () in
*    let ch' = new input_filter ch encoder in
*    ... (* read from ch' *)
*    ch' # close_in();
*    ch  # close_in();  (* you must close both channels! *)
* 

* *