2

I have to convert case in Québec to QUÉBEC, but am unable to do so. Can someone please guide me? In my spec file, I included:

require 'unicode_utils/upcase'

and then I did:

p UnicodeUtils.upcase("Québec", :fr)

and got the following Argument error at run time:

wrong number of arguments (0 or 1+)

I even tried passing nil as the second argument, but got the same error. What am I missing? I got some reference from this question.

$ gem install unicode_utils
$ irb
> require 'unicode_utils'  
=> true  
> UnicodeUtils.downcase("FEN BİLİMLERİ", :tr)  
=> "fen bilimleri"
Community
  • 1
  • 1
user2525211
  • 193
  • 1
  • 1
  • 12
  • It works for me. I posted an answer assuming your require is what's wrong, but that's not it either. Does your error message definitely refer to the line as you have posted it? The `.upcase` method in v1.4.0 takes two params, not `1+` – Neil Slater Sep 06 '13 at 17:12
  • yes, it says"Failure/Error: p UnicodeUtils.upcase("Québec", :fr) Argument Error: Wrong number of arguments (0 or 1+)" .... Is is something that needs to be installed inaddition to the unicode_utils gem? – user2525211 Sep 06 '13 at 17:17
  • Is the second argument ":fr" correct? – user2525211 Sep 06 '13 at 18:43
  • 1
    Works also for me. D you use the actual version of [unicode_utils](http://rubygems.org/gems/unicode_utils) (1.4.0)? – knut Sep 06 '13 at 18:53
  • yes, i did. another observation: when in the console I copy the line UnicodeUtils.upcase("Québec", :fr); instead the following gets copied: UnicodeUtils.upcase("Qu\U+FF3\U+FFA9bec", :fr) and hitting Enter returns "QUBEC" (with the missing accented É after U).. any idea what this string refers to? – user2525211 Sep 06 '13 at 20:22
  • That's cut&paste mis-behaving, and not anything wrong with your test. I get the same error if I cut&paste from the question to IRB on my Mac. When I say "It works for me", I mean that I have used your code from the question as-is, and I get the output `"QUÉBEC"` The argument `:fr` is correct. Could you confirm your file encoding, and that you are using correct Ruby encoding at top of file - e.g. see http://stackoverflow.com/questions/8879237/how-does-the-magic-comment-encoding-utf-8-in-ruby-works – Neil Slater Sep 07 '13 at 06:38
  • Thanks much Neil! Yes, it does work for me too now. Actually, I'm using calabash-ios and rspec framework for automating our ios app testing. In my spec file, I do require 'spec_helper' and require 'calabash-cucumber'. When I was running the above example, i was getting the Wrong number of Arguments. However, when I commented the line "require 'spec_helper'", I did get the correct case conversion output: "QUÉBEC". Quite strange!! Not sure if there is another upcase() methods defined anywhere inaddition to UnicodeUtils.upcase.rb. WHen I go to the declaration, It just shows one upcase method – user2525211 Sep 09 '13 at 16:43
  • any thoughts for how can I confirm this? – user2525211 Sep 09 '13 at 16:44

1 Answers1

1

You can use

"Québec".mb_chars.upcase => QUÉBEC

for non-ASCII characters.

Thanks.