Python lxml, unicode matching in SVG attribute

OmarMS

New Member
I am trying to find an XML element within an SVG (font) file based on the content of an attribute, like so: \[code\]font = et.ElementTree(file='fontfile.svg')glyph = font.find('//n:glyph[@unicode="%s"]' % symbol, namespaces={'n': SVGNS})\[/code\]Glyph examples -- what I'm trying to match to -- are:\[code\]<glyph unicode="©" horiz-adv-x="1792" d="M834 ... -40t-121 -18z " /><glyph unicode="C" horiz-adv-x="1509" d="M1766 338q-49 ... 83.5v-215z" />\[/code\]Problem is that when, for example, \[code\]symbol = "C"\[/code\]it works fine (there is a match), but when \[code\]symbol = "©"\[/code\]it doesn't. I suspect that there is a unicode interpretation in one direction of the matching, but not the other. What is the correct way to resolve this?
 
Back
Top