This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Handling International Encodings
CodeExpectedActual
$KCODE='u'
require 'jcode'
string = "\xef\xbc\xa1" + "\xef\xbc\xa2" + "\xef\xbc\xa3" +
         "\xef\xbc\xa4" + "\xef\xbc\xa5" + "\xef\xbc\xa6"
string.size
18 18
string.jsize
6 6
string.count "\xef\xbc\xa2"
13 13
string.jcount "\xef\xbc\xa2"
1 1
"\xef\xbc\xa2".length
3 3
"\xef\xbc\xa2".jlength
1 1