Encoding

Hi
Source of the previous problem was the encoding.

test.rb:
# encoding: US-8859-1
p __ENCODING__ # says UTF-8 !?!???
...gsub(/ü/,...) # failure

The sourcefile is ISO-8859 (because of bad editor) - (( I want to solve the
ruby-problem, but if we have vi-experts: after :set enc=utf8 :x the file is
still iso?! ))

How can I input an Umlaut,
or can get rid of "invalid multibyte char (utf8)"

Datafile is in utf-8, so the error comes from the source.
Google tells much of Ruby 1.9, but all that didnt help.

Thank you
Berg

The sourcefile is ISO-8859 (because of bad editor)

[snip]

get rid of "invalid multibyte char (utf8)"

Save your source as UTF-8.

but if we have vi-experts [snip]

Really...?!?
Search for "vim save with new file encoding" or similar.

Regards,
Marcus

···

Am 21.04.2016 um 14:23 schrieb A Berger:

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A

Source of the previous problem was the encoding.

test.rb:
# encoding: US-8859-1
p __ENCODING__ # says UTF-8 !?!???

No, what it actually should say is

  unknown encoding name: US-8859-1 (ArgumentError)

Please, do not post pseudo code with typos in it (it's ISO-8859-1),
but actual working code that we can simply copy and paste to verify
your problem.

...gsub(/ü/,...) # failure

I can not reproduce a failure.

Again: please show the *actual* code and the specific error message.

Regards,
Marcus

···

Am 21.04.2016 um 14:23 schrieb A Berger:

--
GitHub: stomar (Marcus Stollsteimer) · GitHub
PGP: 0x6B3A101A

Hi
thats because I cant copy&paste...

x.rb:
!#/usr/bin/ruby
# Encoding: xxx
# encoding=xxx
p __ENCODING__
   # shows "#<Encoding:UTF-8>" (and no error)
   # Ruby version 2.3.0
Sure you'll get the same results...
./x.rb

irb works as expected, mri not.

Berg

??

11:10 ~/testcases[ruby-2.3.0]$ cat > x.rb
#!/usr/bin/env ruby
# Encoding: xxx
p __ENCODING__
11:10 ~/testcases[ruby-2.3.0]$ chmod ugo+x x.rb
11:10 ~/testcases[ruby-2.3.0]$ ./x.rb
./x.rb:2: unknown encoding name: xxx (ArgumentError)
11:11 ~/testcases[ruby-2.3.0]$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]
11:12 ~/testcases[ruby-2.3.0]$

···

On Thu, Apr 21, 2016 at 9:11 AM, A Berger <aberger7890@gmail.com> wrote:

x.rb:
!#/usr/bin/ruby
# Encoding: xxx
# encoding=xxx
p __ENCODING__
   # shows "#<Encoding:UTF-8>" (and no error)
   # Ruby version 2.3.0
Sure you'll get the same results...
./x.rb

irb works as expected, mri not.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan
Consulting Availability : Silicon Valley or remote

thats because I cant copy&paste...

that's ... strange ...

x.rb:
!#/usr/bin/ruby
# Encoding: xxx
# encoding=xxx
p __ENCODING__
   # shows "#<Encoding:UTF-8>" (and no error)
   # Ruby version 2.3.0
Sure you'll get the same results...

No! I already said it works fine for me (using 2.3.0).

Note that the shebang line in your code is wrong;
you really shouldn't expect us to try and figure out what
your problem is when you are too careless or lazy to post
the correct code.

And get a proper mail client and/or editor or whatever it is
that doesn't allow you to copy&paste or you'll never be able
to work productively.

Marcus

···

Am 21.04.2016 um 18:11 schrieb A Berger:

--
GitHub: https://github.com/stomar/
PGP: 0x6B3A101A