search for: each_char

Displaying 7 results from an estimated 7 matches for "each_char".

2006 Mar 14
9
Can you better this String acronym method?
Can you better this String acronym method? def acronym name letters=[] name.each_char {|char| letters<<char if char[0]>=65 and char[0]<=90} acronym = letters.join " " end chris -- Posted via http://www.ruby-forum.com/.
2006 Jul 11
0
malformed utf-8 character error
...tivesupport-1.3.1/lib/active_support/json/encoders/core.rb:31:in `unpack'' D:/EErisken/Downloads/ruby/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/json/encoders/core.rb:31 D:/EErisken/Downloads/ruby/InstantRails/ruby/lib/ruby/1.8/jcode.rb:212:in `each_char'' D:/EErisken/Downloads/ruby/InstantRails/ruby/lib/ruby/1.8/jcode.rb:211:in `each_char'' D:/EErisken/Downloads/ruby/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/json/encoders/core.rb:22 D:/EErisken/Downloads/ruby/InstantRails/ruby/li...
2006 Mar 21
2
How do I get substring of utf-8 string?
I''m trying to get substring from a utf-8 encoded string. (say, first 50 characters of the string) String#[0..49] would give me the first 50 bytes not 50 characters.. I know there is jcode library, but it only let you count number of characters in utf-8 string. unicode gem doesn''t seem to help much. unicode_hacks gem seem to solve the problem, but it also seems to
2007 Aug 27
0
how can I get malformed UTF-8 characters to display properly?
...data.gsub!(/\323/, ''&quot;'') require ''oniguruma'' o = Oniguruma::ORegexp.new(''[^[:ascii:]]'') # o = Oniguruma::ORegexp.new(''[^[:ascii:]]'', {:encoding => Oniguruma::ENCODING_UTF8}) chars = [] data.each_char{|c|chars << c} chars.collect do |c| if o.match c begin "&##{c.unpack(''U*'').first};" rescue ArgumentError add_log_message("Has malformed UTF-8 characters") #handling malformed UTF-8 : a huge pain...
2010 Feb 10
1
metainfo tag called instead of a custom one
...nless subject.nil?}''>#{link}</a>" return [html,false] end private def encode_email( mail ) expanded = mail #mail.gsub(''.'', '' dot '').gsub(''@'', '' at '') entities = "" expanded.each_char { |c| entities << "&##{c[0].ord};"} return entities end end config = Webgen::WebsiteAccess.website.config config[''contentprocessor.tags.map''][''mailto''] = ''Mailto'' config.mailto.to nil, :doc => ''The desti...
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
2006 Jul 12
7
Does anyone work with iso-8859-1 database ?
hello, Our database is in is-8859-1, and I want to update some text fields without success due to some accentuate characters ?? ect ... In my html page (where the charset is iso-8859-19) my textarea display the accentuate characters well and when the user post the form ... I thought that I just need to save it .... without success since ruby map one byte for one character ... So I