Microsoft Edge javascript toLocaleTimeString incorrect spacing -
i'm having trouble understanding going on javascript seems behave differently in edge. boiled down to:
var testi = new date().tolocaletimestring(); var len2 = testi.length; alert(len2);
my length in edge 17, in chrome , ie it's 10 there seems phantom spaces in string, screwed attempting substring it.
https://jsfiddle.net/m1m8h7ym/
fyi time zone central.
looks microsoft slipping in the invisible left-to-right mark. occurs in ie11 in edge mode. figured out looping through each character in string , passing encodeuricomponent()
var output = document.getelementbyid("output"); var testi = new date().tolocaletimestring(); var row; (var = 0, len = testi.length; < len; i++) { row = document.createelement("pre"); row.innerhtml = encodeuricomponent(testi[i]); output.appendchild(row); }
<div id="output"></div>
you strip out removing unicode, can captured in regex expression \u200e
.
var output = document.getelementbyid("output"); var testi = new date().tolocaletimestring().replace(/\u200e/g,""); var row; (var = 0, len = testi.length; < len; i++) { row = document.createelement("pre"); row.innerhtml = encodeuricomponent(testi[i]); output.appendchild(row); }
<div id="output"></div>
Comments
Post a Comment