[前][次][番号順一覧][スレッド一覧]

ruby-changes:2986

From: ko1@a...
Date: 22 Dec 2007 17:11:57 +0900
Subject: [ruby-changes:2986] akr - Ruby:r14478 (trunk): add rdoc.

akr	2007-12-22 17:11:47 +0900 (Sat, 22 Dec 2007)

  New Revision: 14478

  Modified files:
    trunk/encoding.c

  Log:
    add rdoc.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/encoding.c?r1=14478&r2=14477

Index: encoding.c
===================================================================
--- encoding.c	(revision 14477)
+++ encoding.c	(revision 14478)
@@ -250,6 +250,19 @@
     return ENC_DUMMY_P(encoding);
 }
 
+/*
+ * call-seq:
+ *   enc.dummy? => true or false
+ *
+ * Returns true for dummy encoding.
+ * A dummy encoding is a encoding which character handling is not properly
+ * implemented.
+ * It is used for stateful encoding.
+ *
+ *   Encoding::ISO_2022_JP.dummy?       #=> true
+ *   Encoding::UTF_8.dummy?             #=> false
+ *
+ */
 static VALUE
 enc_dummy_p(VALUE enc)
 {
@@ -669,6 +682,15 @@
     return (ONIGENC_IS_ASCII_CODE(c)?ONIGENC_ASCII_CODE_TO_LOWER_CASE(c):(c));
 }
 
+/*
+ * call-seq:
+ *   enc.inspect => string
+ *
+ * Returns a string which represents the encoding for programmers.
+ *
+ *   Encoding::UTF_8.inspect       #=> "#<Encoding:UTF-8>"
+ *   Encoding::ISO_2022_JP.inspect #=> "#<Encoding:ISO-2022-JP (dummy)>"
+ */
 static VALUE
 enc_inspect(VALUE self)
 {
@@ -677,6 +699,14 @@
 		      (ENC_DUMMY_P(self) ? " (dummy)" : ""));
 }
 
+/*
+ * call-seq:
+ *   enc.name => string
+ *
+ * Returns the name of the encoding.
+ *
+ *   Encoding::UTF_8.name       => "UTF-8"
+ */
 static VALUE
 enc_name(VALUE self)
 {
@@ -689,6 +719,22 @@
     return rb_attr_get(self, id_based_encoding);
 }
 
+/*
+ * call-seq:
+ *   Encoding.list => [enc1, enc2, ...]
+ *
+ * Returns the list of loaded encodings.
+ *
+ *   Encoding.list
+ *   => [#<Encoding:ASCII-8BIT>, #<Encoding:EUC-JP>, #<Encoding:Shift_JIS>, #<Encoding:UTF-8>, #<Encoding:ISO-2022-JP (dummy)>]
+ *
+ *   Encoding.find("US-ASCII")
+ *   #=> #<Encoding:US-ASCII>
+ *
+ *   Encoding.list
+ *   => [#<Encoding:ASCII-8BIT>, #<Encoding:EUC-JP>, #<Encoding:Shift_JIS>, #<Encoding:UTF-8>, #<Encoding:US-ASCII>, #<Encoding:ISO-2022-JP (dummy)>]
+ *
+ */
 static VALUE
 enc_list(VALUE klass)
 {
@@ -703,6 +749,16 @@
     return ary;
 }
 
+/*
+ * call-seq:
+ *   Encoding.find(symbol) => enc
+ *   Encoding.find(string) => enc
+ *
+ * Search the encoding with specified <i>name</i>.
+ * <i>name</i> should be a string or symbol.
+ *
+ *   Encoding.find("US-ASCII")  => #<Encoding:US-ASCII>
+ */
 static VALUE
 enc_find(VALUE klass, VALUE enc)
 {
@@ -715,6 +771,24 @@
     return rb_enc_from_encoding(rb_enc_from_index(idx));
 }
 
+/*
+ * call-seq:
+ *   Encoding.compatible?(str1, str2) => enc or nil
+ *
+ * Checks the compatibility of two strings.
+ * If they are compabible, means concatinatable, 
+ * returns an encoding which the concatinated string will be.
+ * If they are not compatible, nil is returned.
+ *
+ *   Encoding.compatible?("\xa1".force_encoding("iso-8859-1"), "b")
+ *   => #<Encoding:ISO-8859-1>
+ *
+ *   Encoding.compatible?(
+ *     "\xa1".force_encoding("iso-8859-1"),
+ *     "\xa1\xa1".force_encoding("euc-jp"))
+ *   => nil
+ *
+ */
 static VALUE
 enc_compatible_p(VALUE klass, VALUE str1, VALUE str2)
 {
@@ -772,6 +846,14 @@
     return rb_enc_from_encoding(rb_default_external_encoding());
 }
 
+/*
+ * call-seq:
+ *   Encoding.default_external => enc
+ *
+ * Returns default external encoding.
+ *
+ * It is initialized by the locale or -E option.
+ */
 static VALUE
 get_default_external(VALUE klass)
 {
@@ -784,6 +866,25 @@
     default_external_index = rb_enc_to_index(rb_to_encoding(encoding));
 }
 
+/*
+ * call-seq:
+ *   Encoding.locale_charmap => string
+ *
+ * Returns the locale charmap name.
+ *
+ *   Debian GNU/Linux
+ *     LANG=C
+ *       Encoding.locale_charmap  => "ANSI_X3.4-1968"
+ *     LANG=ja_JP.EUC-JP
+ *       Encoding.locale_charmap  => "EUC-JP"
+ *
+ *   SunOS 5
+ *     LANG=C
+ *       Encoding.locale_charmap  => "646"
+ *     LANG=ja
+ *       Encoding.locale_charmap  => "eucJP"
+ *
+ */
 VALUE
 rb_locale_charmap(VALUE klass)
 {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]