diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-08-12 16:03:23 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-02-26 21:50:46 +0900 |
commit | 3e5d7e31763362ecf98259755694585902d89f80 (patch) | |
tree | 2b435d14dddfcbbfe3da4f501a5e872c1da234f0 /string.c | |
parent | 0be2049a89bd4288f94205c9dabacac77d2fcc10 (diff) |
[DOC] Move String.new to allow non US-ASCII characters
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5410
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 46 |
1 files changed, 0 insertions, 46 deletions
@@ -1810,52 +1810,6 @@ rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str) return ec_str_duplicate(ec, rb_cString, str); } -/* - * call-seq: - * String.new(string = '') -> new_string - * String.new(string = '', encoding: encoding) -> new_string - * String.new(string = '', capacity: size) -> new_string - * - * Returns a new \String that is a copy of +string+. - * - * With no arguments, returns the empty string with the Encoding <tt>ASCII-8BIT</tt>: - * s = String.new - * s # => "" - * s.encoding # => #<Encoding:ASCII-8BIT> - * - * With the single \String argument +string+, returns a copy of +string+ - * with the same encoding as +string+: - * s = String.new("Que veut dire \u{e7}a?") - * s # => "Que veut dire \u{e7}a?" - * s.encoding # => #<Encoding:UTF-8> - * - * Literal strings like <tt>""</tt> or here-documents always use - * Encoding@Script+encoding, unlike String.new. - * - * With keyword +encoding+, returns a copy of +str+ - * with the specified encoding: - * s = String.new(encoding: 'ASCII') - * s.encoding # => #<Encoding:US-ASCII> - * s = String.new('foo', encoding: 'ASCII') - * s.encoding # => #<Encoding:US-ASCII> - * - * Note that these are equivalent: - * s0 = String.new('foo', encoding: 'ASCII') - * s1 = 'foo'.force_encoding('ASCII') - * s0.encoding == s1.encoding # => true - * - * With keyword +capacity+, returns a copy of +str+; - * the given +capacity+ may set the size of the internal buffer, - * which may affect performance: - * String.new(capacity: 1) # => "" - * String.new(capacity: 4096) # => "" - * - * The +string+, +encoding+, and +capacity+ arguments may all be used together: - * - * String.new('hello', encoding: 'UTF-8', capacity: 25) - * - */ - static VALUE rb_str_init(int argc, VALUE *argv, VALUE str) { |