Fix import of accented characters

This commit is contained in:
Matthias Neeracher 2008-01-27 21:06:35 +00:00
parent b3a5914f3b
commit 3d072d53d5
2 changed files with 24 additions and 6 deletions

View File

@ -3,6 +3,8 @@
# VLLilypondType.reader - Import lilypond files # VLLilypondType.reader - Import lilypond files
# #
$KCODE = 'u'
require File.dirname($0)+'/plistWriter' require File.dirname($0)+'/plistWriter'
require File.dirname($0)+'/vl' require File.dirname($0)+'/vl'
@ -392,12 +394,16 @@ def parseLilypond
tokens[0] = nil tokens[0] = nil
when '\new' when '\new'
if tokens[0] == "Lyrics" if tokens[0] == "Lyrics"
if tokens[1] =~ /^\\/
tokens[0..1] = nil
else
stack.push([block, level, ""]) stack.push([block, level, ""])
block = '\lyricmode' block = '\lyricmode'
level = nestLevel level = nestLevel
STANZAS.push(lyrics= []) STANZAS.push(lyrics= [])
tokens[0..0] = nil tokens[0..0] = nil
end end
end
when '\relative' when '\relative'
stack.push([block, level, ""]) stack.push([block, level, ""])
if tokens[0] =~ /[a-g](?:[ei]?s)?[',]*/ if tokens[0] =~ /[a-g](?:[ei]?s)?[',]*/

View File

@ -15,6 +15,18 @@ class PlistData
end end
end end
def _encodeEntities(string)
encoded = []
string.unpack('U*').each do |ch|
if ch <= 0x7F
encoded << ch
else
encoded.concat("&\##{ch};".unpack('C*'))
end
end
encoded.pack('C*')
end
def _encodePlist(destination, object, indent) def _encodePlist(destination, object, indent)
destination.print " "*indent destination.print " "*indent
case object case object
@ -23,7 +35,7 @@ def _encodePlist(destination, object, indent)
when true then when true then
destination.print "<true/>\n" destination.print "<true/>\n"
when String then when String then
destination.print "<string>#{object}</string>\n" destination.print "<string>#{_encodeEntities(object)}</string>\n"
when PlistData then when PlistData then
destination.print "<data>#{object}</data>\n" destination.print "<data>#{object}</data>\n"
when Integer then when Integer then