Suppose I have a variable that has a unicode value in a Python script.
place_name = u'K\u016bla Mountain'
In this instance, 016b
denotes that a macron accent mark is used over the u
. I want to check for '016b' in the substring and if found, change place_name to u'Kula Mountain'
. If it was just a string, I could use:
if '016b' in place_name:
place_name = 'Kula Mountain'
But that won't work with the unicode value. Whats the simplest way to check for '016b' and if found, change place_name to uncode value of u'Kula Mountain'
?
Note, I tried:
if '016b' in ord(alt_map_name):
place_name = u'Kula Mountain'
as suggested by other posts on this issue, but got
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: ord() expected a character, but string of length 16 found
EDIT: To be clear, I just want to check for the macron
(0x016b), be it with a 'u' or any other letter.