ASCII, non-printable characters etc

Is there a way, to add a ‘hidden’ character to one of two identical strings, so that when they are compared by == it returns false, but they still look identical to the user?
For instance:
String1: “test”
String2: "test "
They would look the same to the user, but I don’t wan’t to necessarily use space as a differentiator.