aboutsummaryrefslogtreecommitdiffstats
path: root/include/ruby/encoding.h
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-14 14:28:10 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-14 14:28:10 +0000
commitc82aee31b41f0772dd0491c6bfa5cb90b47d0d5a (patch)
tree534a3869838473b1443fcfa11c036773d0962d93 /include/ruby/encoding.h
parent87779b507e5b845e81e16dc597a989bc6f2183be (diff)
downloadruby-c82aee31b41f0772dd0491c6bfa5cb90b47d0d5a.tar.gz
* include/ruby/encoding.h (rb_econv_result_t): moved from
transcode_data.h. (rb_econv_elem_t): ditto. (rb_econv_t): ditto. source_encoding and destination_encoding field is added. (rb_econv_open): declared. (rb_econv_convert): ditto. (rb_econv_close): ditto. * transcode.c (rb_econv_open_by_transcoder_entries): initialize source_encoding and destination_encoding field as NULL. (rb_econv_open): make it external linkage. (rb_econv_close): ditto. (rb_econv_convert): ditto. renamed from rb_econv_conv. (make_encoding): new function. (econv_init): use make_encoding and store rb_encoding* in rb_econv_t. (econv_source_encoding): new method Encoding::Converter#source_encoding. (econv_destination_encoding): new method Encoding::Converter#destination_encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/encoding.h')
-rw-r--r--include/ruby/encoding.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index c301b84580..90828f6c2d 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -196,4 +196,45 @@ rb_enc_dummy_p(rb_encoding *enc)
VALUE rb_str_transcode(VALUE str, VALUE to);
+/* econv stuff */
+
+typedef enum {
+ econv_invalid_byte_sequence,
+ econv_undefined_conversion,
+ econv_destination_buffer_full,
+ econv_source_buffer_empty,
+ econv_finished,
+ econv_output_followed_by_input,
+} rb_econv_result_t;
+
+typedef struct {
+ const char *from;
+ const char *to;
+ struct rb_transcoding *tc;
+ unsigned char *out_buf_start;
+ unsigned char *out_data_start;
+ unsigned char *out_data_end;
+ unsigned char *out_buf_end;
+ rb_econv_result_t last_result;
+} rb_econv_elem_t;
+
+typedef struct {
+ rb_econv_elem_t *elems;
+ int num_trans;
+ int num_finished;
+ struct rb_transcoding *last_tc;
+
+ /* The following fields are only for Encoding::Converter.
+ * rb_econv_open set them NULL. */
+ rb_encoding *source_encoding;
+ rb_encoding *destination_encoding;
+} rb_econv_t;
+
+rb_econv_t *rb_econv_open(const char *from, const char *to, int flags);
+rb_econv_result_t rb_econv_convert(rb_econv_t *ec,
+ const unsigned char **input_ptr, const unsigned char *input_stop,
+ unsigned char **output_ptr, unsigned char *output_stop,
+ int flags);
+void rb_econv_close(rb_econv_t *ec);
+
#endif /* RUBY_ENCODING_H */