From 4fa2318b6f166bb16fd21901b7027647ae953d27 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 18 Oct 2008 10:36:20 +0000 Subject: * string.c (rb_external_str_new): a new function to convert from external encoding to internal encoding. if something went wrong, it returns a string with the external encoding. * string.c (rb_external_str_new_with_enc): same as above besides you can specify the source encoding. * ruby.c (ruby_set_argv): use rb_external_str_new() * ruby.c (set_arg0, ruby_script): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/encoding.h | 2 ++ include/ruby/intern.h | 1 + 2 files changed, 3 insertions(+) (limited to 'include/ruby') diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 9049df3fa..1b1cf33d5 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -92,6 +92,8 @@ char* rb_enc_nth(const char*, const char*, int, rb_encoding*); VALUE rb_obj_encoding(VALUE); VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc); +VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *enc); + /* index -> rb_encoding */ rb_encoding* rb_enc_from_index(int idx); diff --git a/include/ruby/intern.h b/include/ruby/intern.h index d99c39636..8e38217aa 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -546,6 +546,7 @@ VALUE rb_str_new5(VALUE, const char*, long); VALUE rb_tainted_str_new_cstr(const char*); VALUE rb_tainted_str_new(const char*, long); VALUE rb_tainted_str_new2(const char*); +VALUE rb_external_str_new(const char*, long); VALUE rb_str_buf_new(long); VALUE rb_str_buf_new_cstr(const char*); VALUE rb_str_buf_new2(const char*); -- cgit