ryanwood/slither — Issue #5: char represented with 2+ bytes, considers 2+ chars
Author: huggaf
Created: 2011-11-08 18:21:12+00:00
State: open

#Person(id: integer, name: string, document: string)
collection = {:body => Person.find(:all) }
Slither.define :people do |d|
d.section :body do |body|
body.column :id, 10, :type => :integer, :padding => :zero
body.column :name, 40, :truncate => true, :align => :left
body.column :document, 15, :truncate => true, :align => :left
end
end

>> puts Slither.generate(:people, collection)
0000044649GILLIARD WEBER xyz2229-0
0000044650JOÃO A GORSKI abc123-22 #Ã uses 2 bytes

collection[:body].first.name += '€' #uses 3 bytes
>> puts Slither.generate(:people, collection)
0000044649GILLIARD WEBER€ xyz2229-0
0000044650JOÃO A GORSKI abc123-22

'€'.size #=> 3
'€'.chars.to_a.size #=> 1

'Ã'.size #=> 2
'Ã'.chars.to_a.size #=> 1