I have a string in unicode and I need to return the first N characters. I am doing this:
result = unistring[:5]
but of course the length of unicode strings != length of characters. Any ideas? The only solution is using re?
Edit: More info
unistring = "Μεταλλικα" #Metallica written in Greek letters
result = unistring[:1]
returns-> ?
I think that unicode strings are two bytes (char), that's why this thing happens. If I do:
result = unistring[:2]
I get
M
which is correct, So, should I always slice*2 or should I convert to something?