Hello,
I am using Arcade to format text for a label. I noticed that the labels do not format correctly when an ampersand is in the attribute that needs to be labeled. For example "Aldi Inc" labels correctly. while "Quist Moving & Storage" does not label correctly.
Label String:
"<FNT name = 'Arial' style = 'Regular' size = '12'>" + $feature.RES_NAME + "</FNT>"
Please let me know how I can label strings with an & in them.
Thank You!
Solved! Go to Solution.
When I just use $feature.TextField, it works:
When I use the label style tags, ArcGIS probably switches to HTML, where ampersand is a special character, so the expression breaks in these features (your code):
"<FNT name = 'Arial' style = 'Regular' size = '12'>" + $feature.TextField + "</FNT>"
You have to escape the ampersand as an HTML entity:
"<FNT name = 'Arial' style = 'Regular' size = '12'>" + Replace($feature.TextField, "&", "&") + "</FNT>"
When I just use $feature.TextField, it works:
When I use the label style tags, ArcGIS probably switches to HTML, where ampersand is a special character, so the expression breaks in these features (your code):
"<FNT name = 'Arial' style = 'Regular' size = '12'>" + $feature.TextField + "</FNT>"
You have to escape the ampersand as an HTML entity:
"<FNT name = 'Arial' style = 'Regular' size = '12'>" + Replace($feature.TextField, "&", "&") + "</FNT>"
The problem is the formatting you have.
Is there a reason why you use coded formatting and not simply specify font and size in the label properties?