Firexox console display issue with unicode char \u00AD
I wrote a javascript function that takes this string of 40 hex characters : "13DE01B7AD467D756FBA1EA816866E32416A269D". It converts every pair of hex chars "13", "DE" to their string counterparts: "?", "Þ", "?", "·", [--0x00AD--] ,"F", "}", "u", "o", "º", "?", "¨", "?", "", "n", "2", "A", "j" , "&", "". and prints them on firefox console using console.log() ... In firefox settings im using default font that is unicode compatible. So every char (converted from pair of hex chars), may it be printable or unprintable, has graphical representation that I can see. Except the char with hex "AD" that is 0x00AD, or decimal 173. That char is "soft hyphen" it should look like short minus sign.
The bug is that DONT SEE the soft hyphen char displayed in console, when there is enough space between the string in which that char resides when printed and end of console element's space, but i DO SEE IT ONLY when that char is the LAST ONE in printed line on console before browser applyes a line break.
I picture1 you can see the above mentioned string of converted hex chars when they have ENOUGH SPACE, and in picture2 you see how IT IS rendered (DISPLAYED) when it is the last one before browser applies line break. You should see soft hyphen before the "F" character
picture1(no soft hyphen): https://ibb.co/fxAD6Q picture2(soft hyphen is there): https://ibb.co/etaD6Q
Обране рішення
Усі відповіді (6)
Then why not replace these non printable characters?
s="13DE01B7AD467D756FBA1EA816866E32416A269D"; t=[];for(i=0;s[i];i+=2){t.push("%"+s.substr(i,2).replace(/AD/i,"-"))} x=unescape(t.join("")); console.log(t,x);
Yes, i know how to replace characters. It's just that I'm writing a HMAC_SHA1 function that at some point the code spits out string of character like above explained, in order for me to troubleshoot working of function itself by being able to copy-paste characters from console and then use the clipboard to insert the string on sites like this one: https://caligatio.github.io/jsSHA
What I think is that above behavior is a bug, it can't be that printable character like \u00AD is sometimes displayed in console and sometimes is not, and that it depends on (how it seems) on location of that char, that is on a line break of a browser ( or width of the console window). That is ridiculous. What is more amazing is that this bug is cross browser issue. Strange...
Can you share any information or why this behaviour exists and what might be the cause of it?! Thx for your help and your time.
Also, your solution adds a ASCII char with hex 0x39 that is just ascii. And I whould like to copy/paste exact representation of characters in string that HMAC_SHA1 that im trying to write returns. I can go around it, but Im curious about this weird appearing of "soft hyphen char".
The 'shy' character isn't displayed, but is there if I copy the text to the clipboard.
?Þ?·F}uoº?¨?n2Aj&
Þ·­F}uoº ¨†n2Aj&
Вибране рішення
Thnx cor-el! It's behaviour is like that because thats the sole purpose of soft hyphen. :) Not a bug, for sure.