Wednesday, May 4, 2016

ruby openbsd terminal FIX invalid byte sequence in UTF-8 (ArgumentError)

Today i start playing with ruby and an small script that reads a csv file and create users in openbsd os the file was simply username, plain password, comments but the comments also have the ñ letter on it so i did not know that for some reason ruby does not handle this automatically at least in openbsd terminal so when i connect to openbsd with putty terminal and run it i was getting this error

./++++++.rb:6:in `split': invalid byte sequence in UTF-8 (ArgumentError)
        from ./++++++.rb:6:in `block in <main>'
        from ./++++++.rb:5:in `each'
        from ./++++++.rb:5:in `<main>'

so i remember this kind of errors with python, so i searched in google and put the normal encode solution in the script:

#encoding: utf-8

didn't work :\ so in some page said that the problem was not ruby or the encoding in the script but the terminal encoding so i have to put the correct enconding in the profile file and that worked !! 

export LC_CTYPE=xy_XY.ISO8859-1

how did i get the encoding type

$locale -a

No comments:

Post a Comment