Just noticed that some strings (taken from an array created from a m3u playlist file) won’t work due to a malformed hexadecimal character escape sequence.
var strArray = [
"#EXTM3U",
"C:\music\X Marks the Pedwalk - Desolation.mp3", //fine
"#EXTINF:287,Xandria - Ginger Sunset Expire", //fine
"C:\music\andria - Ginger Sunset Expire.mp3", //fine
"C:\music\xandria - Ginger Sunset Expire.mp3", // FAILS
"C:\\music\\xandria - Ginger Sunset Expire.mp3" //fine
]
alert (strArray);
I can get around it with escape slashes. But my question is what is actually causing the error. I thought it might be something to do with \x but that would mean the first track would also fail. So I’m a little bit confused.
No, because
xandXare not the same character. 🙂\x(with thexin lower case) is special in string literals,\X(with theXin upper case) is not.Best practice is to always escape backslashes that are meant to really be backslashes as opposed to the beginning of an escape sequence. Otherwise, you will trip yourself up.