Displaying 9 results from an estimated 9 matches for "each_byt".
Did you mean:
each_byte
2010 Dec 05
3
Strange problem with CSV and funny chars
...'] I get the following strange results which I
cannot understand.
(rdb:1) row[''price'']
"\xA32.00"
(rdb:1) row[''price''][0]
"\xA3"
(rdb:1) row[''price''][0] == "\xA3"
false
(rdb:1) row[''price''][0].each_byte{|c| print c, '' ''}
163 "\xA3"
(rdb:1) "\xA3".each_byte{|c| print c, '' ''}
163 "\xA3"
(rdb:1) "\xA3".class
String
(rdb:1) row[''price''][0].class
String
(rdb:1) row[''price''][0] <=> &quo...
2006 May 09
2
Computing very large exponents
Greetings all.
Does anyone have a clue how to use Ruby to do modular exponentiation
using the binary left-to-right method? I looked through the
documentation and searched the forums and found the String.each_byte
method. However I had no luck finding anything showing how one might
manipulate bits of bytes.
Below is an example of what I am talking about.
The calculation a = b^e mod n (or in Ruby: a = (b ** e).modulo(n) )is
known as modular exponentiation. One efficient method to carry this out
on a...
2005 Apr 21
9
Screen capture, save to file
Is there anything in the utils to capture a screen ( or maybe just a
window) and save to a file.
I have this, but I have no idea where it came from, but it gives a
corrupted image
Paul
# -*- ruby -*-
# screen capture --
# This script runs with a Ruby/DL which is included in ruby-1.7.
require ''dl/import''
module ScreenCapture
extend DL::Importable
dlload
2009 Oct 20
10
REXML
...de>0</override>
<aspectRatio>0.8999999762000001</aspectRatio>
</ozml>
EOF
xml = string.gsub(''"'',"''")
I need to use loop below <text> tag generating object values dynamically
.
How to embed this in xml ?
end_title_name.each_byte do |title|
"<object value=title/>"
end
thanks,
sri..
--
Posted via http://www.ruby-forum.com/.
2006 Aug 14
0
loading an image to instance variable of AR
...osition
=>"inline")
This is the code I did in my model, that not works ;-(, no error, but
the image is not render wth the send_data
def defaultImage
@waitingImage=[]
file=File.open("#{RAILS_ROOT}/public/images/picture.jpg", "r")
file.each_byte do |abyte|
@waitingImage << abyte
end
return @waitingImage
end
thanks
arnaud
2006 Mar 03
0
binary_to_string/string_to_binary confusion
...39;'
assert @data == bin.data, ''Data differs from original after save''
but the generated SQL is invalid because it attempts to insert raw
binary into the database.
If I implement them as follows:
def self.hex_encode(value)
retvalue = ""
value.each_byte do |b|
retvalue << sprintf("%02X", b)
end
retvalue
end
def self.hex_decode(value)
retvalue = ""
value.scan(/../) do |h|
c = h.hex
retvalue << c.chr
end
retvalue
end...
2006 Mar 12
2
Find all the methods on a object in an irb session?
How can I find all the methods on an object from withing irb?
Thanks,
Joe
2007 Aug 27
0
how can I get malformed UTF-8 characters to display properly?
...begin
"&##{c.unpack(''U*'').first};"
rescue ArgumentError
add_log_message("Has malformed UTF-8 characters")
#handling malformed UTF-8 : a huge pain and possibly future
cause of problems
bytes = []
c.each_byte{|b| bytes << b}
# assumes we''re handling at most, 2-byte strings. We have
no way if the malformed character is
# supposed to be one byte or two, but we''re assuming it''s 1.
["&##{bytes[0]}"] + bytes[1..-1].collect{|b|b.ch...
2006 Jul 18
8
Including files from lib/
I asked about this a few days ago and got no replies, so I''m asking again.
I have a file called string_extensions.rb. In it, I extend the String class
to include some extra functionality. I put this file into the lib/ directory
of my app.
But the changes made to String don''t take effect. The program acts as though
the files aren''t being included.
I''ve stopped