special characters (&) with Text formatting tags

4227
3
Jump to solution
08-17-2020 03:42 AM
DavidHofmann
New Contributor III

Hi,

I use text formatting tags to get different text sizes within one label. The Problem ist, that there is a "&" in some of my name-attributes. It seams, that these "&"-characters are interpreted as part of the formatting tags. Is there a possibility to tell ArcGIS Pro Framework, that the "&" should not be interpreted as part of the formatting tags?

(It would not be a problem to write a exclusion-tag into my name-attribute field, since I only use them for labeling.)

My Label Expression is:

$feature.NAME + "\n" + "<FNT size= '12'>" +"(" +  $feature.NUMBER + " TEXT)" + "</FNT>"

$feature.name containes the "&" character in some cases. In these cases the Lebel in the maps is:

"NAME" <FNT size='12'>(NUMBER TEXT)<\FNT>

              <FNT size='12'>(NUMBER TEXT)<\FNT>

So the tags are part of the shown labels and the part which has the Lebels appears two times there.

Does anybody know a solution or a hint, what I can try to solve the problem?

Thanks

David

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

On the Text Formatting tags documentation page, it mentions special characters:

The ampersand (&) and angle bracket (<) are special characters and are not valid in your text if formatting tags are used. Use the equivalent character codes &amp; and &lt; instead.

below that, it also shows to to replace them in your code

If you have special characters embedded in the values of the label field, you can replace them dynamically using a simple label script.

Label Expression - Arcade

"<BOL>" + replace($feature.Notes, "&", "&amp;") + "</BOL>"

Label Expression - VBScript

Function FindLabel ([LABELFIELD])
   NewString = Replace([LABELFIELD],"&","&amp;")
   FindLabel = "<ITA>" & NewString & "</ITA>"
End Function

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

On the Text Formatting tags documentation page, it mentions special characters:

The ampersand (&) and angle bracket (<) are special characters and are not valid in your text if formatting tags are used. Use the equivalent character codes &amp; and &lt; instead.

below that, it also shows to to replace them in your code

If you have special characters embedded in the values of the label field, you can replace them dynamically using a simple label script.

Label Expression - Arcade

"<BOL>" + replace($feature.Notes, "&", "&amp;") + "</BOL>"

Label Expression - VBScript

Function FindLabel ([LABELFIELD])
   NewString = Replace([LABELFIELD],"&","&amp;")
   FindLabel = "<ITA>" & NewString & "</ITA>"
End Function
DavidHofmann
New Contributor III

Hi Ken,

thank you so much, your solution works perfectly!

0 Kudos
CRose
by
New Contributor III

Thanks, very helpful! 

 

Your "text formatting tags" link is broken now. I couldn't find this information about special characters in the official dynamic text documentation.