Skip to content

Commit

Permalink
This commit breaks one of the RTF files I have.
Browse files Browse the repository at this point in the history
Revert "Deal with unicode characters like the spec demands."

This reverts commit 99d60cc.
  • Loading branch information
dj2 committed Sep 5, 2012
1 parent 055612c commit fe1896f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/ruby-rtf/parser.rb
Expand Up @@ -174,13 +174,22 @@ def handle_control(name, val, src, current_pos)
when :cf then add_section!(:foreground_colour => @doc.colour_table[val])
when :cb then add_section!(:background_colour => @doc.colour_table[val])
when :hex then current_section[:text] << val
when :uc then
raise "Can't deal with uc != 0 yet" if val != 0
when :uc then @skip_byte = val.to_i
when :u then
if @skip_byte && @skip_byte == 0
val = val % 100
@skip_byte = nil
end
if val == 32 || val == 8232
add_modifier_section({:newline => true}, "\n")
else
current_section[:text] << val.chr('utf-8')
val += 65_536 if val < 0
char = if val < 10_000
[val.to_s.hex].pack('U*')
else
[val].pack('U*')
end
current_section[:text] << char
end

when *[:rquote, :lquote] then add_modifier_section({name => true}, "'")
Expand Down

0 comments on commit fe1896f

Please sign in to comment.