Invalid multibyte char!

hey
i am teaching myself to code right now and encountered a problem.

this is my code and for some reasin i get a error message:
def deutscheZahl zahl
  if zahl < 0
    return 'minus ' +(deutscheZahl (-1) +zahl)
  end
  if zahl ==0
    return 'null'
  end
  if zahl ==1
    return 'eins'
  end

  zahlString = ''

  einer =['ein', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben',
'acht', 'neun']
  zehner =%w{zehn zwanzig dreißig vierzig fünfzig sechzig siebzig achzig
neunzig}
  teenager =%w{elf zwölf dreizehn vierzehn fünfzehn sechzehn siebzehn
achtzehn neunzehn}

  if zahl <1000
    h=zahl/100
    z=zahl/10%10
    e=zahl%10
  end

  if h>0
    zahlString=zahlString + einer[h-1]+'hundert'
  end

  if z==1 && e>0
    zahlString = zahlString + teenager[e-1]
  else
    if e>0
      zahlString=zahlString+ einer[e-1]
    if z>0
      zahlString = zahlString +'und'
    end
    end
    return zahlString
  end

wert = ["", 'tausend', 'millionen', 'milliarden', 'billionen']
w=0

  while zahl > 0
    z = zahl%1000
    if z>0
      zahlString = (deutscheZahl z)+wert[w] + zahlString
    end
    w=w+1
    zahl = zahl/1000
  end
  return zahlString
end

puts "welche zahl sollen wir ausschreiben?"
puts deutscheZahl(gets.chomp)

C:\Programmieren\Rails\Ruby1.9.3\bin\ruby.exe -e
$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
C:/Users/Finn/RubymineProjects/deutscheZahl/deutscheZahl
-e:1:in `load':
C:/Users/Finn/RubymineProjects/deutscheZahl/deutscheZahl:14: invalid
multibyte char (US-ASCII) (SyntaxError)
C:/Users/Finn/RubymineProjects/deutscheZahl/deutscheZahl:14: invalid
multibyte char (US-ASCII)
C:/Users/Finn/RubymineProjects/deutscheZahl/deutscheZahl:14: syntax
error, unexpected $end, expecting ']'
...', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben', 'acht...
... ^
  from -e:1:in `<main>'

Process finished with exit code 1

what is wrong?

big thanks in advance :slight_smile:

···

--
Posted via http://www.ruby-forum.com/.

Also, when it says "deutscheZahl:14" it means "look at file deutscheZahl line 14" which is the line with the umlaut.

It doesn't like the umlaut in "fünf". You have to tell Ruby that this
script file (the actual text file, with your ruby source code in) is
encoded in something other than US-ASCII.

Try adding this comment as the first line in your script file:

# encoding: UTF-8

That way, as soon as the Ruby parser opens the file, it knows to
interpret "fünf" as four UTF-8 characters, rather than five raw octets
("\x66\xC3\xBC\x6E\x66"), two of which aren't valid 7-bit US-ASCII.

Google "ruby magic encoding comment" for further reading.

···

--
Posted via http://www.ruby-forum.com/.

danke sehr der code läuft jetzt :slight_smile: es gab noch probleme mit ß und ein
bisschen syntax. danke für eure hilfe :slight_smile:

···

--
Posted via http://www.ruby-forum.com/.