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
#
$KCODE = 'u'
require File.dirname($0)+'/plistWriter'
require File.dirname($0)+'/vl'
@ -392,12 +394,16 @@ def parseLilypond
tokens[0] = nil
when '\new'
if tokens[0] == "Lyrics"
if tokens[1] =~ /^\\/
tokens[0..1] = nil
else
stack.push([block, level, ""])
block = '\lyricmode'
level = nestLevel
STANZAS.push(lyrics= [])
tokens[0..0] = nil
end
end
when '\relative'
stack.push([block, level, ""])
if tokens[0] =~ /[a-g](?:[ei]?s)?[',]*/

View File

@ -15,6 +15,18 @@ class PlistData
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)
destination.print " "*indent
case object
@ -23,7 +35,7 @@ def _encodePlist(destination, object, indent)
when true then
destination.print "<true/>\n"
when String then
destination.print "<string>#{object}</string>\n"
destination.print "<string>#{_encodeEntities(object)}</string>\n"
when PlistData then
destination.print "<data>#{object}</data>\n"
when Integer then