Issue
I write a simple code in python but I encountered a very different problem. Python sees the same 2 text differently, and moreover notepad++ & diffchecker.com does this at. How is this possible?
First text:
RMX.jeeperscreepers203.rar
Second Text:
RMX.jeeperscreepers203.rar
Do not use CTRL+F because Browser see this text is same. Here is files:
Here is a diffchecker link: https://www.diffchecker.com/WDaUgaoG/
Here is .txt file (2 line): https://wetransfer.com/downloads/5cfb21084fcab97fb0b05d40d07aef9520231222192643/fc021b
Solution
The first line on your .txt file has the following Unicode code points:
U+0052 U+004D U+0058 U+002E U+006A U+0065 U+0065 U+0070 U+0065 U+0072 U+0073 U+0063 U+0072 U+0065 U+0065 U+0070 U+0065 U+0072 U+0073 U+0032 U+0030 U+0033 U+002E U+0072 U+0061 U+0072
while the second line has the following code points:
U+0052 U+004D U+0058 U+002E U+FEFF U+006A U+0065 U+0065 U+0070 U+0065 U+0072 U+0073 U+0063 U+0072 U+0065 U+0065 U+0070 U+0065 U+0072 U+0073 U+0032 U+0030 U+0033 U+002E U+0072 U+0061 U+0072
This can be checked on any Unicode-to-code-point viewer, such as this website.
Diff-ing that would show an additional U+FEFF
code point on position 5 at the second text, which is a byte order mark character.
If you want the two texts to be the same, filter only the printable characters:
import string
text1 = "RMX.jeeperscreepers203.rar"
text2 = "RMX.jeeperscreepers203.rar"
text1 = ''.join(filter(str.isprintable, text1))
text2 = ''.join(filter(str.isprintable, text2))
if text1 == text2:
print("Same text")
else:
print("Not same")
Answered By - enzo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.