Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something wrong with encoding in AndroidNotification #175

Closed
coffebar opened this issue Oct 31, 2015 · 5 comments
Closed

Something wrong with encoding in AndroidNotification #175

coffebar opened this issue Oct 31, 2015 · 5 comments
Assignees
Milestone

Comments

@coffebar
Copy link

coffebar commented Oct 31, 2015

def notify(title, message):
    return AndroidNotification().notify(title=title, message=message)

notify(u'Vk Service', u'Нет новых сообщений')

and i see this notification:

s51101-014425

but next works without such problems:

class MyApp(App):
    def build(self):
        return Label(text=u'Привет')

2015-10-31 23 54 50

What can I do to localize notifications?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Kovak
Copy link
Contributor

Kovak commented Nov 1, 2015

Make sure the encoding on your supplied strings is utf-8 as that is what plyer is expecting.

@coffebar
Copy link
Author

coffebar commented Nov 1, 2015

I'm using unicode strings ( u'...' )
Look at method _notify in AndroidNotification class,
I see ".encode('utf-8')" there:

def _notify(self, **kwargs):
    icon = getattr(Drawable, kwargs.get('icon_android', 'icon'))
    noti = NotificationBuilder(activity)
    noti.setContentTitle(AndroidString(
        kwargs.get('title').encode('utf-8')))
    noti.setContentText(AndroidString(
        kwargs.get('message').encode('utf-8')))
    noti.setSmallIcon(icon)
    noti.setAutoCancel(True)

    if SDK_INT >= 16:
        noti = noti.build()
    else:
        noti = noti.getNotification()

    self._get_notification_service().notify(0, noti)

double "encode" leads to exception:

selection_140

@coffebar
Copy link
Author

coffebar commented Nov 2, 2015

I made demo app to demonstrate problem, may be this will help to solve it.

@IvanTheFirst
Copy link

I had problem with sms example, maybe this is the same? Try this:
unicode(str('я').strip(codecs.BOM_UTF8), 'utf-8')

this will clean utf8 header from the Python string

@KeyWeeUsr
Copy link
Contributor

Right now I could display not only cyrillic characters, but even emoji characters in the notification. Please check with either the latest stable (1.3.2) or even master branch. New release will come soon.

@KeyWeeUsr KeyWeeUsr added this to the 1.3.3 milestone Dec 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants