I used a simple approach to satisfiy my need - 1. take the the last byte of each bangla digit, and 2. subtract by last byte of bangla digit '0'. Converting the whole number is even simpler. Here is my code -
def self.translate_number_from_bangla(p_bn_number)
en_number = 0
length = p_bn_number.length
for i in 1..length/3 do
cur_digit = p_bn_number[3*i-1].to_i - 166
if cur_digit >= 0 && cur_digit <= 9
en_number *= 10
en_number += cur_digit
end
end
return en_number
end
1 comment:
Thank you dada. It helps me.
Post a Comment