⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Encoding
/
View File Name :
cdesc-Encoding.ri
U:RDoc::NormalClass[iI" Encoding:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[Oo:RDoc::Markup::Paragraph;[I"PAn Encoding instance represents a character encoding usable in Ruby. It is ;TI"Kdefined as a constant under the Encoding namespace. It has a name and ;TI"optionally, aliases:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[ I"Encoding::ISO_8859_1.name ;TI"#=> "ISO-8859-1" ;TI" ;TI" Encoding::ISO_8859_1.names ;TI"%#=> ["ISO-8859-1", "ISO8859-1"] ;T:@format0o; ;[I"PRuby methods dealing with encodings return or accept Encoding instances as ;TI"Narguments (when a method accepts an Encoding instance as an argument, it ;TI"6can be passed an Encoding name or alias instead).;T@o;;[I""some string".encoding ;TI"#=> #
;TI" ;TI"9string = "some string".encode(Encoding::ISO_8859_1) ;TI"#=> "some string" ;TI"string.encoding ;TI" #=> #
;TI" ;TI"'"some string".encode "ISO-8859-1" ;TI"#=> "some string" ;T;0o; ;[ I"IEncoding::ASCII_8BIT is a special encoding that is usually used for ;TI"Ia byte string, not a character string. But as the name insists, its ;TI">characters in the range of ASCII are considered as ASCII ;TI"Icharacters. This is useful when you use ASCII-8BIT characters with ;TI"'other ASCII compatible characters.;T@S:RDoc::Markup::Heading: leveli: textI"Changing an encoding;T@o; ;[I"NThe associated Encoding of a String can be changed in two different ways.;T@o; ;[ I"MFirst, it is possible to set the Encoding of a string to a new Encoding ;TI"Kwithout changing the internal byte representation of the string, with ;TI"OString#force_encoding. This is how you can tell Ruby the correct encoding ;TI"of a string.;T@o;;[I"string ;TI" #=> "R\xC3\xA9sum\xC3\xA9" ;TI"string.encoding ;TI" #=> #
;TI",string.force_encoding(Encoding::UTF_8) ;TI"#=> "R\u00E9sum\u00E9" ;T;0o; ;[ I"OSecond, it is possible to transcode a string, i.e. translate its internal ;TI"Nbyte representation to another encoding. Its associated encoding is also ;TI"Kset to the other encoding. See String#encode for the various forms of ;TI"Ptranscoding, and the Encoding::Converter class for additional control over ;TI"the transcoding process.;T@o;;[ I"string ;TI"#=> "R\u00E9sum\u00E9" ;TI"string.encoding ;TI"#=> #
;TI"3string = string.encode!(Encoding::ISO_8859_1) ;TI"#=> "R\xE9sum\xE9" ;TI"string.encoding ;TI"!#=> #
;T;0S; ;i;I"Script encoding;T@o; ;[I"NAll Ruby script code has an associated Encoding which any String literal ;TI"6created in the source code will be associated to.;T@o; ;[I"GThe default script encoding is Encoding::UTF_8 after v2.0, but it ;TI"Gcan be changed by a magic comment on the first line of the source ;TI"Bcode file (or second line, if there is a shebang line on the ;TI"Ffirst). The comment must contain the word
coding
or ;TI"H
encoding
, followed by a colon, space and the Encoding ;TI"name or alias:;T@o;;[ I"# encoding: UTF-8 ;TI" ;TI""some string".encoding ;TI"#=> #
;T;0o; ;[I"SThe
__ENCODING__
keyword returns the script encoding of the file ;TI""which the keyword is written:;T@o;;[ I"# encoding: ISO-8859-1 ;TI" ;TI"__ENCODING__ ;TI" #=> #
;T;0o; ;[ I"O
ruby -K
will change the default locale encoding, but this is ;TI"Pnot recommended. Ruby source files should declare its script encoding by a ;TI"Mmagic comment even when they only depend on US-ASCII strings or regular ;TI"expressions.;T@S; ;i;I"Locale encoding;T@o; ;[I"JThe default encoding of the environment. Usually derived from locale.;T@o; ;[I"9see Encoding.locale_charmap, Encoding.find('locale');T@S; ;i;I"Filesystem encoding;T@o; ;[I"MThe default encoding of strings from the filesystem of the environment. ;TI"5This is used for strings of file names or paths.;T@o; ;[I"$see Encoding.find('filesystem');T@S; ;i;I"External encoding;T@o; ;[I"OEach IO object has an external encoding which indicates the encoding that ;TI"PRuby will use to read its data. By default Ruby sets the external encoding ;TI"Lof an IO object to the default external encoding. The default external ;TI"Sencoding is set by locale encoding or the interpreter
-E
option. ;TI"IEncoding.default_external returns the current value of the external ;TI"encoding.;T@o;;[I"ENV["LANG"] ;TI"#=> "UTF-8" ;TI"Encoding.default_external ;TI"#=> #
;TI" ;TI";$ ruby -E ISO-8859-1 -e "p Encoding.default_external" ;TI"#
;TI" ;TI"4$ LANG=C ruby -e 'p Encoding.default_external' ;TI"#
;T;0o; ;[ I";The default external encoding may also be set through ;TI"OEncoding.default_external=, but you should not do this as strings created ;TI"Pbefore and after the change will have inconsistent encodings. Instead use ;TI"L
ruby -E
to invoke ruby with the correct external encoding.;T@o; ;[I"OWhen you know that the actual encoding of the data of an IO object is not ;TI"Mthe default external encoding, you can reset its external encoding with ;TI"JIO#set_encoding or set it at IO object creation (see IO.new options).;T@S; ;i;I"Internal encoding;T@o; ;[ I"ITo process the data of an IO object which has an encoding different ;TI"Rfrom its external encoding, you can set its internal encoding. Ruby will use ;TI"Nthis internal encoding to transcode the data when it is read from the IO ;TI"object.;T@o; ;[I"QConversely, when data is written to the IO object it is transcoded from the ;TI"Ainternal encoding to the external encoding of the IO object.;T@o; ;[I";The internal encoding of an IO object can be set with ;TI"CIO#set_encoding or at IO object creation (see IO.new options).;T@o; ;[I"JThe internal encoding is optional and when not set, the Ruby default ;TI"Linternal encoding is used. If not explicitly set this default internal ;TI"Fencoding is +nil+ meaning that by default, no transcoding occurs.;T@o; ;[I"JThe default internal encoding can be set with the interpreter option ;TI"M
-E
. Encoding.default_internal returns the current internal ;TI"encoding.;T@o;;[I"-$ ruby -e 'p Encoding.default_internal' ;TI" nil ;TI" ;TI"D$ ruby -E ISO-8859-1:UTF-8 -e "p [Encoding.default_external, \ ;TI"# Encoding.default_internal]" ;TI"1[#
, #
] ;T;0o; ;[ I";The default internal encoding may also be set through ;TI"OEncoding.default_internal=, but you should not do this as strings created ;TI"Pbefore and after the change will have inconsistent encodings. Instead use ;TI"L
ruby -E
to invoke ruby with the correct internal encoding.;T@S; ;i;I"IO encoding example;T@o; ;[I"ZIn the following example a UTF-8 encoded string "R\u00E9sum\u00E9" is transcoded for ;TI"Noutput to ISO-8859-1 encoding, then read back in and transcoded to UTF-8:;T@o;;[I"!string = "R\u00E9sum\u00E9" ;TI" ;TI"4open("transcoded.txt", "w:ISO-8859-1") do |io| ;TI" io.write(string) ;TI" end ;TI" ;TI"puts "raw text:" ;TI"&p File.binread("transcoded.txt") ;TI" puts ;TI" ;TI":open("transcoded.txt", "r:ISO-8859-1:UTF-8") do |io| ;TI" puts "transcoded text:" ;TI" p io.read ;TI" end ;T;0o; ;[I"MWhile writing the file, the internal encoding is not specified as it is ;TI"Oonly necessary for reading. While reading the file both the internal and ;TI"Fexternal encoding must be specified to obtain the correct result.;T@o;;[I"$ ruby t.rb ;TI"raw text: ;TI""R\xE9sum\xE9" ;TI" ;TI"transcoded text: ;TI""R\u00E9sum\u00E9";T;0: @fileI"encoding.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ;I"transcode.c;T;0;0;0[ [ [ [[I" class;T[[:public[[I"aliases;TI"encoding.c;T[I"compatible?;T@[I"default_external;T@[I"default_external=;T@[I"default_internal;T@[I"default_internal=;T@[I" find;T@[I" list;T@[I"locale_charmap;T@[I"name_list;T@[:protected[ [:private[ [I" instance;T[[;[[I"ascii_compatible?;T@[I"dummy?;T@[I"inspect;T@[I" name;T@[I" names;T@[I"replicate;T@[I" to_s;T@[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@òI")ext/openssl/lib/openssl/buffering.rb;TI".ext/psych/lib/psych/visitors/yaml_tree.rb;TI"lib/cgi/core.rb;TI"lib/cgi/util.rb;TI"lib/csv.rb;TI"lib/csv/row.rb;TI"lib/fileutils.rb;TI"lib/find.rb;TI"lib/irb.rb;TI"&lib/irb/lc/ja/encoding_aliases.rb;TI"lib/irb/xmp.rb;TI"lib/net/http/response.rb;TI"lib/net/imap.rb;TI"lib/open-uri.rb;TI"lib/rdoc/options.rb;TI"+lib/rubygems/commands/setup_command.rb;TI"lib/rubygems/package.rb;TI""lib/rubygems/specification.rb;TI"lib/rubygems/util.rb;TI"'lib/unicode_normalize/normalize.rb;TI"lib/uri/common.rb;TI"lib/uri/generic.rb;TI"lib/uri/rfc2396_parser.rb;T@õ@õcRDoc::TopLevel