Last active
August 29, 2015 14:01
-
-
Save foxweb/077614da940aa84050ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 10000000000 | |
Benchmark.bm do |x| | |
x.report { puts "hello йё".force_encoding("ISO-8859-1").encode("UTF-8") } # насильно в латиницу и обратно в UTF | |
x.report { puts "hello йё".encode("UTF-8").force_encoding('UTF-8') } # из UTF и в UTF | |
x.report { puts "hello йё".encode("UTF-8", invalid: :replace, undef: :replace, replace: "?") } # мягкое исправление ошибок кодировки | |
x.report { puts "hello йё" } # как есть | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment