itabtabai
unread,Jan 7, 2012, 9:11:26 PM1/7/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nokogiri-talk
I am a Ruby beginner who happens to be using it just because of
Nokogiri.
I have developed a code that does the conversion of digit glyphs from
Arabic to Arab-indic. The code does the job well. So I am not asking
for help to debug it.
I rather wondering if any of the advanced users on the list could give
a more eloquent code. I ask this because I think eloquence gives more
insight into Nokogir.
Here is the code:
=begin
iFile = File.open('01 copy.html', "r")
@doc = Nokogiri::HTML(iFile, nil, 'UTF-8')
iFile.close
@doc.css('section.pagenumber').each do |e|
a =
["٠","١","٢","٣","٤","٥","٦","٧","٨","٩"] #
index represents arab-indic glyph
ainum =
""
# string to store arab-indic glyph
anum = e.content.match(/
\d{1,3}/) # extract arabic glyphs
anum.to_s.each_char {|c| ainum = ainum + a[c.to_i]} #
converting arabic glyph to arab-indic
e.content = "— #{ainum}
—" # finally assigning the
arabic-indic to the element
end
puts @doc.css('section.pagenumber')
=end