Labels not showing special characters

1621
12
Jump to solution
03-21-2023 12:06 PM
JordanSeider
New Contributor III

I have labels on my map that contain special characters as parts of place names (examples: ʔ, ·, ⱡ). They appear correct in the attribute table but on the display and when I export as a PDF, the characters change to "?". 

Tags (3)
0 Kudos
2 Solutions

Accepted Solutions
JordanSeider
New Contributor III

Had to manually change the special characters to a different, unique string of characters (eg., "$#a", "$#b", etc.). Then, I managed some success with a label expression in Python:

 

def FindLabel([Label]):
    new = [Label].replace("$#a", "ʔ").replace("$#b", "q̓").replace("$#c", "ō").replace("$#c", "ō").replace("$#d", "á").replace("$#e", "é").replace("$#f", "ŝ").replace("$#g", "ś").replace("$#h", "ū").replace("$#i", "·").replace("$#j", "ⱡ")
    return new

 

For example: I would write the Label field for "abʔcⱡde" as "ab$#ac$#jde" and then use the expression above to plot the labels with the correct characters.

View solution in original post

Mahdi_Ch
New Contributor III

Happy to hear it's resolved. Although I think there should be a better way for the first part to not do that manually. I will add that later if I figure out. 

By the way, to make this function more general to work in other cases and also to avoid writing very long lines which are hard to read and are prone to error,  you can define all the changes in a dictionary and pass the key and value pairs of that dictionary to replace().

 

# a dictionary that can define required changes
# This way it can be edited easily
changes = {"$#a": "ʔ",
           "$#b": "q̓",
           "$#c": "ō",
           "$#c": "ō",
           "$#d": "á",
           "$#e": "é",
           "$#f": "ŝ",
           "$#g": "ś",
           "$#h": "ū",
           "$#i": "·",
           "$#j": "ⱡ"}

def fix_label_char(label:str, change_dict:dict, report:bool=False)->str:
    """Takes a str(text)and a dictionry of changes
        then applies it to the text and
        returns the new text (if any changes made),
        otherwise original text gets returned.
        It can also print the changes if report=True 
        report is off by default """
    
    new_label = label
    for key,val in change_dict.items():
        new_label = new_label.replace(key, val)
    
    # report section
    if label == new_label and report: 
        print(f'No changes applied to {label}!')
    elif label != new_label and report: 
        print(f'Changed {label} ---> {new_label}')
    else:
        pass
        
    return new_label

 

 

View solution in original post

12 Replies
SLouq
by MVP Regular Contributor
MVP Regular Contributor

make sure eyou are using the right formatting in your label expressions.

https://community.esri.com/t5/arcgis-pro-questions/special-characters-with-text-formatting-tags/td-p...

0 Kudos
JordanSeider
New Contributor III

Unfortunately, I cannot find any HTML codes for the characters I need. 

0 Kudos
KenBuja
MVP Esteemed Contributor

Have you tried other fonts that contain those special characters?

0 Kudos
JordanSeider
New Contributor III

Okay, I have found the relevant HTML codes. My label expression is as follows but no matter what font I try, it does not change the label.

 

Function FindLabel ([CmmntN1])
   NewString = Replace([CmmntN1], "ⱡ", "ⱡ")
   NewString = Replace([CmmntN1], "ʔ", "ʔ")
   NewString = Replace([CmmntN1], "·", "·")
   FindLabel = NewString
End Function

 

 

 

 

0 Kudos
JordanSeider
New Contributor III

Now I realize, even after updating the attribute table with the correct symbols and saving the edits, when I reopen the attribute table, the characters return to ?.

0 Kudos
SLouq
by MVP Regular Contributor
MVP Regular Contributor

If you are not getting attributes in your attribute table the only thing I can think of is the data type for that field is wrong. 

0 Kudos
JordanSeider
New Contributor III

The attributes are fine, just those few special characters change from ʔ to ?

0 Kudos
SLouq
by MVP Regular Contributor
MVP Regular Contributor

Look at your field length in field view

0 Kudos
JordanSeider
New Contributor III

Field is "text" and length is 80

0 Kudos