Skip to content

Instantly share code, notes, and snippets.

@np422
Created January 17, 2012 10:16
Show Gist options
  • Save np422/1626090 to your computer and use it in GitHub Desktop.
Save np422/1626090 to your computer and use it in GitHub Desktop.
>> s = "Räksmörgås".encode Encoding::ISO8859_1
=> "R\xE4ksm\xF6rg\xE5s"
>> Benchmark.measure { 100000.times { a = s.encoding != Encoding::UTF_8 ? s.encode(Encoding::UTF_8) : s } }
=> 2.590000 0.010000 2.600000 ( 2.585933)
>> s = "Räksmörgås"
=> "Räksmörgås"
>> Benchmark.measure { 100000.times { a = s.encoding != Encoding::UTF_8 ? s.encode(Encoding::UTF_8) : s } }
=> 0.010000 0.000000 0.010000 ( 0.014274)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment