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:ocument.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 ???
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:ocument.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 ???