I just deployed a couple classes from my sandbox to production, and a specifically formatted character was replaced within my code. Dashes that are immediately surrounded by spaces in my sandbox class ended up as question marks in production. Has anyone ever seen something like this before?

Sandbox code:

 Map<String, Integer> regionCounts = new Map<String, Integer>{'International-APAC'=>0, 'International-EMEA'=>0, 'International – LATAM'=>0, 'North America – East'=>0, 'North America – West'=>0};

How it ended up in production:

Map<String, Integer> regionCounts = new Map<String, Integer>{'International-APAC'=>0, 'International-EMEA'=>0, 'International ? LATAM'=>0, 'North America ? East'=>0, 'North America ? West'=>0};

I'm aware I could just remove the spaces and update the values as they are used in our instance, but it's not quite that simple, and this obviously appears to be a bug of some kind. If you're writing comments and type out a dash in the above fashion, why should it get replaced as a question mark?

I also notice that after I save the code in edit mode, said dashes appear longer on the detail page, similar word processor auto formatting: enter image description here

I've already filed a case with Salesforce, but we only have basic support and I have a feeling I'm going to get the run-around before they'll escalate to engineering, so thought I'd check to see if anyone has run into anything similar.

  • 2
    Seems like some form of character encoding issue. Are you saving the file via the browser rather than a separate IDE? – Daniel Ballinger Dec 19 '13 at 1:20
  • This sounds extremely odd. When you pull the metadata down from your Sandbox using Ant, does it have the question mark or does that only appear with a deploy to prod? – Jesse Altman Dec 19 '13 at 1:23
  • 3
    Did you by chance every copy/paste said code through a word processor? It almost seems like your dash has been replaced by an em dash, which word "helpfully" does automatically. – ca_peterson Dec 19 '13 at 1:27

Those dashes may look the same, but they aren't.

If I copy your code over to Notepad++ and highlight one of the later 3 dashes only the last 3 are highlighted as matching.

enter image description here

The quick answer would be to retype your dash characters so they are all the same.

You are probably dealing with 3 possible characters:

  • a hyphen symbol - (Alt+45)
  • an em dash — (Alt+0151)
  • an en dash – (Alt+0150)

Telling them apart will mostly depending on your font etc...

Going back to your code. The characters for APAC and EMEA are hypens. LATAM, NA-East, and NA-West all have en dashes.

So why are your en dashes appearing as question marks? Most likely there is an encoding transition occurring at some point. I.e. transitioning from ISO-8859-1 to UTF-8 encoding.

Here is what happens in Notepad++ when I change the encoding from ANSI to UTF-8. enter image description here

  • Well I feel like quite the buffoon. I believe I copied the values from free text fields and didn't think about possible encoding issues. Odds are those values themselves were originally copied and pasted in from a word processor. Indeed deleting the characters and re-entering them solved the problem. Thanks – kbentsen Dec 19 '13 at 2:56
  • No problem. It was one of those things I learnt the hard way too and has certainly caught me out in the past. – Daniel Ballinger Dec 19 '13 at 5:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.