1

I am using Carmen gem to get countries and respective states.but, when I use Carmen::Country.named("Sri Lanka").subregions.collect{|p| p.name}, I am getting this array:

["Basnāhira paḷāta",
 "Madhyama paḷāta",
 "Dakuṇu paḷāta",
 "Uturu paḷāta",
 "Næ̆gĕnahira paḷāta",
 "Vayamba paḷāta",
 "Uturumæ̆da paḷāta",
 "Ūva paḷāta",
 "Sabaragamuva paḷāta"]

and after using I18n, I am getting:

["Basnahira pa?ata",
 "Daku?u pa?ata",
 "Madhyama pa?ata",
 "Nae?genahira pa?ata",
 "Sabaragamuva pa?ata",
 "Uturu pa?ata",
 "Uturumae?da pa?ata",
 "Uva pa?ata",
 "Vayamba pa?ata"]

With ? replacing a special characters.

Robert
  • 10,403
  • 14
  • 67
  • 117
saibharath
  • 63
  • 5
  • 1
    what do you mean when you say "after using I18n" – Mike H-R Apr 24 '14 at 11:06
  • to avoid special characters from the states array i used i18n like this -- I18n.transliterate("Basnāhira paḷāta") and it's replacing the special character and giving --> "Basnahira pa?ata". and how can i get rid of these special characters. – saibharath Apr 24 '14 at 11:15
  • I think, I18n simply cannot transliterate that characters.. What do you want to achieve? – roman-roman Apr 24 '14 at 11:17
  • i want to convert these characters to English language – saibharath Apr 24 '14 at 14:15
  • You'll need to create transliteration rules as I said in my answer if you want to do that. – Mike H-R Apr 24 '14 at 15:30
  • @MikeH-R, still i am unable to convert some of the special characters like.. æ ,z̧ Z̧ (event though i have i18n trasilterate rules for these lettters).. only these characters are left out to convert, but remaining all special characters were successfully converted. – saibharath Jul 16 '14 at 10:13

1 Answers1

0

transliterate changes non ascii characters to ascii characters approximations, any characters for which there are no approximations are replaced with ?. this is explained in the docs. If this is not what you want to do, you do not want to use the transliterate method.

If you want to write your own transliteration approximations do it like so (from the docs I linked to):

i18n:
  transliterate:
    rule:
      ü: "ue"
      ö: "oe"
Mike H-R
  • 7,726
  • 5
  • 43
  • 65