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 "?".
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
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.
Thanks! And yes, my coding experience is limited to R so I kind of just brute-forced my way through StackExchange to make that expression for this particular use-case. I just wished that the Arc attribute table would preserve the special characters.
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
Have you tried other fonts that contain those special characters?
Unfortunately, I cannot find any HTML codes for the characters I need.
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/539055
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.