plyer icon indicating copy to clipboard operation
plyer copied to clipboard

Wrong SMS example, app crashes when your try to use unicode symbols

Open IvanTheFirst opened this issue 9 years ago • 1 comments

Hello, I think there is some error in sms example ( https://github.com/kivy/plyer/tree/master/examples/sms ). Your should use smstext = unicode(self.sms_message.strip(codecs.BOM_UTF8), 'utf-8') sms.send(recipient=self.sms_recipient, message=smstext)

instead of sms.send(recipient=self.sms_recipient, message=self.sms_message) For some languages your need to use utf16.

https://docs.python.org/2/howto/unicode.html

Unicode character U+FEFF is used as a byte-order mark (BOM), and is often written as the first character of a file in order to assist with autodetection of the file’s byte ordering. Some encodings, such as UTF-16, expect a BOM to be present at the start of a file; when such an encoding is used, the BOM will be automatically written as the first character and will be silently dropped when the file is read. There are variants of these encodings, such as ‘utf-16-le’ and ‘utf-16-be’ for little-endian and big-endian encodings, that specify one particular byte ordering and don’t skip the BOM.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/28833480-wrong-sms-example-app-crashes-when-your-try-to-use-unicode-symbols?utm_campaign=plugin&utm_content=tracker%2F77151&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77151&utm_medium=issues&utm_source=github).

IvanTheFirst avatar Dec 03 '15 22:12 IvanTheFirst

Note: Python 2.7 support is no longer required. Call to unicode() may need to be reconsidered.

Julian-O avatar Oct 26 '23 02:10 Julian-O