sivashanmugam kannan sivashanmugam kannan - 5 months ago 8
Node.js Question

String has hidden characters, Can't able to verify ,

I asked a question some 2 hours before

[Not required to see the question, Just a reference ]
Storing images using node.js gives error

The solution given was was literally the same of my code, I tried to find the difference between my code and his code to see what's the modification he did to make it work, But there is nothing modified.

So i thought of trying it online IDE and i tried c9.io online IDE to check it. But suddenly something showed up little bit strange in the online c9.io IDE which my local sublime editor did't show it.

The below image is text which i saw in sublime, Which does't have any
difference.

enter image description here



-

The below is the text i found in c9.io . As you can see clearly there is
two dots
showed up newly in c9.io javascript editor.

enter image description here




I could not able to see the difference that in normal text editor, Then in online
different checker also showed the error.


enter image description here

Ths below is the text which has the hidden difference between two strings

AybükeArslan‌​_(3).JPG

AybükeArslan_(3).JPG



Just copy paste the above text in https://www.diffchecker.com/ after then you could see the difference between the above
two strings


Can anyone tell what's the reason for this and how to remove the unwanted characters from the string through a javascript function. It's been giving one hell of a problem for 5 hours in my server.

Answer

There are 2 Unicode characters between the n and the _, a ‌ zero width non-joiner followed by a zero width space.

Seeing them will depend on the editor/font you use and how it decides to display this class of non-printable character - if at all.

To remove them:

newStr = oldStr.replace(/[\u200c\u200b]/g, "");
Comments