We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Ruby
- Strings
- Ruby - Strings - Iteration
- Discussions
Ruby - Strings - Iteration
Ruby - Strings - Iteration
Sort by
recency
|
51 Discussions
|
Please Login in order to post a comment
def count_multibyte_char(s) s.chars.filter{ |char| char.each_byte.size > 1 }.count end
I ended up with:
str.each_char.select {|ch| ch.each_byte.count > 1}.count
def count_multibyte_char(string) string. each_char. count { |char| char.each_byte.count > 1 } end
I am typescript-react developer in a well-known organization in Pakistan. i am also handling two remote projects, one is from lahore based small e-commerce company's store and the other one is Karachi based e-commerce store SL Basics. As a developer it is too hard to take care of your eyes thats why i mostly use rose water.
def count_multibyte_char(data) count = 0 data.each_char {|d| count +=1 if d.bytesize > 1} count
end