D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
String
/
Filename :
encode-i.ri
back
Copy
U:RDoc::AnyMethod[iI"encode:ETI"String#encode;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"JReturns a copy of +self+ transcoded as determined by +dst_encoding+. ;TI"/By default, raises an exception if +self+ ;TI"Lcontains an invalid byte or a character not defined in +dst_encoding+; ;TI"Bthat behavior may be modified by encoding options; see below.;To:RDoc::Markup::BlankLine o; ; [I"With no arguments:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"KUses the same encoding if <tt>Encoding.default_internal</tt> is +nil+ ;TI"(the default):;T@o:RDoc::Markup::Verbatim; [I"(Encoding.default_internal # => nil ;TI"3s = "Ruby\x99".force_encoding('Windows-1252') ;TI"=s.encoding # => #<Encoding:Windows-1252> ;TI"<s.bytes # => [82, 117, 98, 121, 153] ;TI"/t = s.encode # => "Ruby\x99" ;TI"=t.encoding # => #<Encoding:Windows-1252> ;TI"Ft.bytes # => [82, 117, 98, 121, 226, 132, 162] ;T:@format0o;;0; [o; ; [I"EOtherwise, uses the encoding <tt>Encoding.default_internal</tt>:;T@o;; [I")Encoding.default_internal = 'UTF-8' ;TI".t = s.encode # => "Ruby™" ;TI"6t.encoding # => #<Encoding:UTF-8> ;T;0o; ; [I"AWith only argument +dst_encoding+ given, uses that encoding:;T@o;; [ I"3s = "Ruby\x99".force_encoding('Windows-1252') ;TI"9s.encoding # => #<Encoding:Windows-1252> ;TI"*t = s.encode('UTF-8') # => "Ruby™" ;TI"2t.encoding # => #<Encoding:UTF-8> ;T;0o; ; [I"=With arguments +dst_encoding+ and +src_encoding+ given, ;TI"Yinterprets +self+ using +src_encoding+, encodes the new string using +dst_encoding+:;T@o;; [I"s = "Ruby\x99" ;TI":t = s.encode('UTF-8', 'Windows-1252') # => "Ruby™" ;TI"Bt.encoding # => #<Encoding:UTF-8> ;T;0o; ; [I"EOptional keyword arguments +enc_opts+ specify encoding options; ;TI"Fsee {Encoding Options}[rdoc-ref:encodings.rdoc@Encoding+Options].;T@o; ; [ I"GPlease note that, unless <code>invalid: :replace</code> option is ;TI"Igiven, conversion from an encoding +enc+ to the same encoding +enc+ ;TI"K(independent of whether +enc+ is given explicitly or implicitly) is a ;TI"Ino-op, i.e. the string is simply copied without any changes, and no ;TI"<exceptions are raised, even if there are invalid bytes.;T: @fileI"transcode.c;T:0@omit_headings_from_table_of_contents_below0I"�encode(dst_encoding = Encoding.default_internal, **enc_opts) -> string encode(dst_encoding, src_encoding, **enc_opts) -> string ;T0[ I"(*args);T@MFI"String;TcRDoc::NormalClass00