Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

invalid byte sequence in utf-8 ruby

irb(main):079:0> File.write("file.txt", "vandflyver xC5rhus")
=> 16
irb(main):080:0> open("file.txt", "r") { |io| io.read.encode("UTF-8", invalid: :replace) }
=> "vandflyver �rhus"
irb(main):081:0> open("file.txt", "r") { |io| io.read.encode("UTF-8", invalid: :replace, replace: "") }
=> "vandflyver rhus"
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #invalid #byte #sequence #ruby
ADD COMMENT
Topic
Name
1+5 =