0

I have some pretty simple Apex code, something like this:

private static final String X = 'ABC';
// String y is read from a CSV file.
System.debug('<' + y + '>');    // Outputs: <ABC>
System.debug(y == X);           // Outputs: false

Having read a number of articles about ==, equals, etc. this does not make sense. What is going on here?

1 Answer 1

2

After two hours of banging my head against various walls, I finally copied the debug line from the Salesforce log to Notepad++ and there I saw this:

enter image description here

I have no idea what ZWNBSP is, but it sure messes up the comparison. On screen, this character is not visible, only Notepad++ shows it to me.

The CSV was created by Excel, as a UTF-8 file. Notepad++ tells me it's a UTF-8-BOM file, it doesn't show that character in the file itself. The string ABC is the first text in this file, and apparently you get something extra if you just start reading this file in Apex (via Blob.toString).

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .