You can also use user defined template functions to do one of two things:
- Remove non unicode characters as you requested:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val):
string_encode = val.encode("ascii", "ignore")
string_decode = string_encode.decode()
return string_decode
you can use the new function like this:
Code:
program:
s = 'ᕼ ᗩ ᒪ ᖴ - ᒪ I ᖴ ᗴ';
remove_unicode_characters(s)
- Make lookup replacement for unicode characters:
Code:
def evaluate(self, formatter, kwargs, mi, locals, val):
lookup = {
'ᕼ': 'H',
'ᗩ': 'A',
'ᒪ': 'L',
'ᖴ': 'F',
'ᗴ': 'E'
}
new_string = ''
for ch in val:
new_string += lookup.get(ch, ch)
return new_string
You need to expand the lookup dictionary (highlighted in blue) to include any additional unicode characters you want.
You can use this new function as follows
Code:
program:
s = 'ᕼ ᗩ ᒪ ᖴ - ᒪ I ᖴ ᗴ';
unicode_lookup(s)
Notes- To add the new functions described above: preferences > template functions > template functions tab > copy-paste in the program code box and enter the name of the function (highlighted above in green) in the function box.
- For both functions the argument count should be set to 1.