package gapi-ocaml
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=b84b680528a5e050014103a8e7a60a5d43efd5fefc3f838310bd46769775ab48
md5=8ee26acf1f6c6f5e24c7b57fa070a0a2
doc/gapi-ocaml.netstring-local/Netconversion/class-conversion_pipe/index.html
Class Netconversion.conversion_pipe
Source
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! *)
*
* *
inherit Netchannels.in_obj_channel
inherit Netchannels.out_obj_channel