First - a short description of a problem. I write a JavaScript function to put some text label's in SVG canvas. Here it is:
function set_label(x,y,title)
{
var newTitle = document.createElementNS(svgNS,"text");
newTitle.setAttributeNS(null,"x",x);
newTitle.setAttributeNS(null,"y",y);
newTitle.setAttributeNS(null,"font-size","17px");
newTitle.setAttributeNS(null,"font-family","WinGreek");
var textNode = document.createTextNode(title);
newTitle.appendChild(textNode);
document.getElementById("viewport").appendChild(newTitle);
}
I must use Greek font due to my project points. So, I call function:
set_label (10,50,'Qitos')
this will display Ktitos label - no problem.
But - when i try to call like this:
set_label (10,50,'QamÚraj')
or even worse:
set_label (10,50,'Θαρσανδαλα')
this must display Θαρσανδαλα title formed all from special characters - a problem accrue - utf-8 symbol appear like i write it - with code :(
After some research here in other similar question's, i find that if I convert UTF-8 code to ESC sequence, like \U00B0 - this must solve that problem, but... - I cant figure it how to do this and - how to do that if special character is in middle of string - like second example