Invalid multibyte char (UTF-8) on Windows command prompt

Hi, I’m not really a programmer by career. My experience limits to learning Pascal way back in school and extended experience doing VBA on Office so I want to step up and I want to learn the Ruby language. I just installed Ruby using Rubyinstaller.org on Windows 10. I selected the “set all external text as UTF-8” just in case during installation. and then installed both ruby and MYSYS2 devkit.

I set to test some simple code using “Start command Prompt with Ruby” but as soon as I tried to execute a rb file I got “invalid multibyte char (UTF-8)” regarding lines which have string literals like:

puts "Probar el número."

I already tried using the magic encoding comment at the beginning of the file:

# encoding: UTF-8

to no avail. Curiously, if I try:

puts "test string".encoding

I do get UTF-8.

Although I can restrict myself to ASCII chars for a while, inability to use accented vowels and other symbols and letters like ¿ and ñ is hampering. Where can I look for in order to fix this issue?

Ok I kind of got it solved for now.

I just downloaded the trial version of RubyMine and when I opened the document there it showed me the characters with the ? sign so I quickly edited them there and saved the file and it nows runs as expected.

I need to check into the Notepad format since apparently it must be saving the .rb file in a such a way that Unicode characters don’t get recognized as such.

Well, will be sticking to learning the basics for now. If anyone has useful tutorials or reference for a aspiring Ruby programmer, let me now!

If anyone has useful tutorials or reference for a aspiring Ruby programmer, let me now!

If you’re looking for a Rails book, Michael Martl’s book is one of the best. You can find it on Amazon or at his site railstutorial.org

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs