Get the number of bytes needed for a Unicode string

Viewed 2320

I have a Korean string encoded as Unicode like u'정정'. How do I know how many bytes are needed to represent this string?

I need to know the exact byte count since I'm using the string for iOS push notification and it has a limit on the size of the payload.

len('정정') doesn't work because that returns the number of characters, not the number of bytes.

3 Answers
Related