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

Only Ascii characters accepted #76

Open
samschott opened this issue Nov 24, 2020 · 3 comments · May be fixed by #78
Open

Only Ascii characters accepted #76

samschott opened this issue Nov 24, 2020 · 3 comments · May be fixed by #78

Comments

@samschott
Copy link

samschott commented Nov 24, 2020

It appears that only input not accepted. The basic issue lies in getchar:

bullet/bullet/utils.py

Lines 52 to 55 in 75f620d

if c in string.printable:
return c
else:
return UNDEFINED_KEY

where string.printable contains only printable ASCII characters. This leaves all people with wider utf-8 input in the cold.

@a-luna
Copy link

a-luna commented Feb 6, 2021

A response to the stackoverflow post, Test if a python string is printable, provides a clever way to check for non-printable characters:

def is_printable(s):
    return not any(repr(ch).startswith("'\\x") or repr(ch).startswith("'\\u") for ch in s)

Replacing the check in utils.py to use this function would allow any utf-8 printable input to be used:

if is_printable(c):
    return c
else:
    return UNDEFINED_KEY

I'll create a PR with this change, hopefully it will be accepted since allowing utf-8 input should be a requirement (IMO).

@jab
Copy link

jab commented Feb 6, 2021

str.startswith optionally takes a tuple of strings to try. Better to write the above as not any(repr(ch).startswith(("'\\x", "'\\u")) for ch in s)

@a-luna
Copy link

a-luna commented Feb 6, 2021

I had no idea that you could provide a tuple to startswith, thank you for pointing that out! The updated version will be in the PR.

@a-luna a-luna linked a pull request Feb 6, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants