Fix for ruby1.9.3.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8739 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-01-30 22:53:53 +00:00
parent 682efe399d
commit 7abaa570c6
1 changed files with 14 additions and 4 deletions

View File

@ -98,7 +98,7 @@ module Redmine
def textstring(s) def textstring(s)
# Format a text string # Format a text string
if s.chars.first == '<' # This means the string is hex-dumped. if s =~ /^</ # This means the string is hex-dumped.
return s return s
else else
return '('+escape(s)+')' return '('+escape(s)+')'
@ -146,11 +146,21 @@ module Redmine
end end
def Bookmark(txt, level=0, y=0) def Bookmark(txt, level=0, y=0)
utf16 = Iconv.conv('UTF-16', 'UTF-8', txt)
if (y == -1) if (y == -1)
y = GetY() y = GetY()
end end
@outlines << {:t => utf16, :l => level, :p => PageNo(), :y => (@h - y)*@k} @outlines << {:t => txt, :l => level, :p => PageNo(), :y => (@h - y)*@k}
end
def bookmark_title(txt)
txt = begin
utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
hextxt = "<FEFF" # FEFF is BOM
hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
hextxt << ">"
rescue
txt
end || ''
end end
def putbookmarks def putbookmarks
@ -184,7 +194,7 @@ module Redmine
n=self.n+1 n=self.n+1
@outlines.each_with_index do |o, i| @outlines.each_with_index do |o, i|
newobj() newobj()
out('<</Title '+textstring(o[:t])) out('<</Title '+bookmark_title(o[:t]))
out("/Parent #{n+o[:parent]} 0 R") out("/Parent #{n+o[:parent]} 0 R")
if (o[:prev]) if (o[:prev])
out("/Prev #{n+o[:prev]} 0 R") out("/Prev #{n+o[:prev]} 0 R")