i have output from a server like
["alex", "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd"]
i want to convert it like
[“alex”, “to its right language”]
using js or jquery
i tried
function encode_utf8( s )
{
return unescape( encodeURIComponent( s ) )
}
but not working correctly
any help?
thanks in advance
I am not sure about what you mean by getting output “LIKE” the shown example…
but if you get
["alex", "\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd"]and assign it to a variable likefor example if you pass in correct character codes like:
Try the examples above in a browser console (works at least for me in current Chrome)
On the other hand if you receive
"\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd"every time then I assume similar to the commentors that your response already gets messed up before you are handling it in JavaScriptThis article shows nicely that using Unicode characters is valid for variable naming so the same should apply to string content.