extra single quote

U

Une bévue

from time to time, i get extra single quote within a string which
doesn't contains single quote at all ???

here is the context :

@browsers_folders_aliases={"Opera" => [],
"SeaMonkey" => ["Personal Toolbar
Folder"],
"Netscape" => ["Personal Toolbar
Folder"],
"Firefox" => ["Barre personnelle",
"Toolbar Bookmarks"],
"Shiira" => ["BookmarksBar"],
"Safari" => ["BookmarksBar"],
"Flock" => ["Bookmarks Toolbar Folder"],
"Camino"=>["Bookmark Bar"]
}


the extra single quote appears in that function :


def getFolderLabelToInsert(browser, xml)
aliases=@browsers_folders_aliases[browser]
case(aliases.length)
when 0:
return ''
when 1:
return aliases[0]
else
labels=getLabels(xml)
labels.each { |label| return label if aliases.include? label}
end
end


where browser is one of the possible browsers on MacOS X xml an xml
file.

the function getLabels make use of REXML :

def getLabels(xml)
doc = REXML::Document.new File.new("#{xml}")
labels=[]
doc.root.elements.each("folder") { |e| labels <<
e.attributes["label"]}
return labels
end

printing out intermediate result of getLabels() doesn't show up single
quote :
["Barre personnelle", "Recherches rapides"]
["BookmarksBar", "BookmarksMenu"]

the only output of getFolderLabelToInsert(browser, xml) gives an extra
quote :

"label1 = Barre personnelle"
"label2 = BookmarksBar'"
----------------------^-

obviously i've found a workaround (by gsub) however because it isn't the
first time i get this extra single quote, i wonder if others got also
such a behaviour ???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top