Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

1 Answer

up vote 5 down vote accepted

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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