0

The following hash is causing a syntax error. I assume it is because of the funky characters.

Any way to fix this? I'm using macvim, in case that matters.

  {
    :en => ['English',  'en_US'], 
    :es => ['español',  'es_MX'],
    :fr => ['français', 'fr_FR'],
    :de => ['Deutsch',  'de_DE'],
    :ru => ['русский',  'ru_RU'],
    :zh => ['中国的',   'zh_CN'],
    :ar => ['العربية',   'ar_AR'],
  }
pixelearth
  • 13,674
  • 10
  • 62
  • 110
  • 2
    Instead of assuming, determine the *minimal* failing case. Then you'll have something better as a question and it changes from "What?" to "Why?" and "How to resolve?" Also, post the *exact syntax error*. –  Jan 24 '13 at 06:52
  • Does this answer your question? http://stackoverflow.com/questions/3484071/unicode-characters-in-a-ruby-script – perimosocordiae Jan 24 '13 at 06:53
  • Don't assume, just read the thing. It tells you exactly what is wrong. – Jörg W Mittag Jan 24 '13 at 11:25

2 Answers2

2

If this is Ruby 1.9, then you can set the magic comment to tell Ruby this is a UTF8 file instead of ASCII:

How does the magic comment ( # Encoding: utf-8 ) in ruby​​ work?

Community
  • 1
  • 1
Jim Deville
  • 10,632
  • 1
  • 37
  • 47
0

You could always escape your unicode values.

{
  :en => ['English',  'en_US'], 
  :es => ['espa\u00F1ol',  'es_MX'],
  :fr => ['fran\u00E7ais', 'fr_FR'],
  :de => ['Deutsch',  'de_DE'],
  :ru => ['\u0440\u0443\u0441\u0441\u043A\u0438\u0439',  'ru_RU'],
  :zh => ['\u4E2D\u56FD\u7684',   'zh_CN'],
  :ar => ['\u0627\u0644\u0639\u0631\u0628\u064A\u0629',   'ar_AR'],
}
Jason Sperske
  • 29,816
  • 8
  • 73
  • 124