Sets the replacement string.
ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace) ec.replacement = "<undef>" p ec.convert("a \u3042 b") #=> "a <undef> b"
Prettify (indent) an HTML string.
string
is the HTML string to indent. shift
is the indentation unit to use; it defaults to two spaces.
print CGI.pretty("<HTML><BODY></BODY></HTML>") # <HTML> # <BODY> # </BODY> # </HTML> print CGI.pretty("<HTML><BODY></BODY></HTML>", "\t") # <HTML> # <BODY> # </BODY> # </HTML>
Resets the digest to the initial state and returns self.
This method is overridden by each implementation subclass.
If none is given, returns the resulting hash value of the digest, keeping the digest’s state.
If a string is given, returns the hash value for the given string, resetting the digest to the initial state before and after the process.
Returns the resulting hash value and resets the digest to the initial state.
If none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest’s state.
If a string is given, returns the hash value for the given string in a hex-encoded form, resetting the digest to the initial state before and after the process.
Returns the resulting hash value in a hex-encoded form and resets the digest to the initial state.
Returns digest_obj.hexdigest().
If none is given, returns the resulting hash value of the digest in a base64 encoded form, keeping the digest’s state.
If a string
is given, returns the hash value for the given string
in a base64 encoded form, resetting the digest to the initial state before and after the process.
In either case, the return value is properly padded with ‘=’ and contains no line feeds.
Returns the resulting hash value and resets the digest to the initial state.
Creates a class to wrap the C struct described by signature
.
MyStruct = struct ['int i', 'char c']
Construct a new class given a C:
class klass
(CUnion
, CStruct
, or other that provide an entity_class)
types
(Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types constants)
corresponding members
Fiddle::Importer#struct
and Fiddle::Importer#union
wrap this functionality in an easy-to-use manner.
Examples:
require 'fiddle/struct' require 'fiddle/cparser' include Fiddle::CParser types, members = parse_struct_signature(['int i','char c']) MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members) MyStruct.malloc(Fiddle::RUBY_FREE) do |obj| ... end obj = MyStruct.malloc(Fiddle::RUBY_FREE) begin ... ensure obj.call_free end obj = MyStruct.malloc begin ... ensure Fiddle.free obj.to_ptr end
Construct a new class given a C:
class klass
(CUnion
, CStruct
, or other that provide an entity_class)
types
(Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types constants)
corresponding members
Fiddle::Importer#struct
and Fiddle::Importer#union
wrap this functionality in an easy-to-use manner.
Examples:
require 'fiddle/struct' require 'fiddle/cparser' include Fiddle::CParser types, members = parse_struct_signature(['int i','char c']) MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members) MyStruct.malloc(Fiddle::RUBY_FREE) do |obj| ... end obj = MyStruct.malloc(Fiddle::RUBY_FREE) begin ... ensure obj.call_free end obj = MyStruct.malloc begin ... ensure Fiddle.free obj.to_ptr end
Get the next 8bit byte. Raises EOFError
on EOF
Reads size bytes from the stream. If buf is provided it must reference a string which will receive the data.
See IO#read
for full details.
Reads at most maxlen bytes from the stream. If buf is provided it must reference a string which will receive the data.
See IO#readpartial
for full details.
Reads a line from the stream which is separated by eol.
Raises EOFError
if at end of file.
Reads a one-character string from the stream. Raises an EOFError
at end of file.
Reads a DER or PEM encoded string from string or io and returns an instance of the appropriate PKey
class.
string is a DER- or PEM-encoded string containing an arbitrary private or public key.
io is an instance of IO
containing a DER- or PEM-encoded arbitrary private or public key.
pwd is an optional password in case string or io is an encrypted PEM resource.
Return true
if the PRNG has been seeded with enough data, false
otherwise.
Start streaming using encoding
ad hoc workaround for broken registry
Generate a Form element as a string.
method
should be either “get” or “post”, and defaults to the latter. action
defaults to the current CGI
script name. enctype
defaults to “application/x-www-form-urlencoded”.
Alternatively, the attributes can be specified as a hash.
See also multipart_form()
for forms that include file uploads.
form{ "string" } # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM> form("get") { "string" } # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM> form("get", "url") { "string" } # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM> form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
Generate a reset button Input element, as a String
.
This resets the values on a form to their initial values. value
is the text displayed on the button. name
is the name of this button.
Alternatively, the attributes can be specified as a hash.
reset # <INPUT TYPE="reset"> reset("reset") # <INPUT TYPE="reset" VALUE="reset"> reset("VALUE" => "reset", "ID" => "foo") # <INPUT TYPE="reset" VALUE="reset" ID="foo">