package gapi-ocaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=3a9e7ba4446b90f842c10dc2e49211c394c9f012715da01bb0b80baccabb41bb
md5=27919a0188772392e9b74bfd95fbaaa1
doc/gapi-ocaml.netstring-local/Netconversion/class-conversion_pipe/index.html
Class Netconversion.conversion_pipeSource
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_channelinherit Netchannels.out_obj_channel