facebook / PathPicker

PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything. After parsing the input, PathPicker presents you with a nice UI to select which files you're interested in. After that you can open them in your favorite editor or execute arbitrary commands.
https://facebook.github.io/PathPicker/
MIT License
5.11k stars 282 forks source link

Chinese language support! #294

Open sbraveyoung opened 5 years ago

sbraveyoung commented 5 years ago

Hey, I'm Chinese, and my system language of CentOS is Chinese yet. I use fpp with git status, but all of Chinese character are become messy code, it's very unfriendly. Is there has any solution to solve it? THX very much~

pcottle commented 5 years ago

Oh yeah there might not be utf8 support. Can you try using python3?

From: Younger notifications@github.com Reply-To: facebook/PathPicker reply@reply.github.com Date: Wednesday, November 21, 2018 at 7:31 PM To: facebook/PathPicker PathPicker@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [facebook/PathPicker] Chinese language support! (#294)

Hey, I'm Chinese, and my system language of CentOS is Chinese yet. I use fpp with git status, but all of Chinese character are become messy code, it's very unfriendly. Is there has any solution to solve it? THX very much~

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/facebook/PathPicker/issues/294, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABFRn_C2UD95O01qHrbF0sgOv0huQiSDks5uxgxhgaJpZM4Yuj42.

sbraveyoung commented 5 years ago

Oh, thanks a lot. I modify the fpp scripts that 'python' to 'python36', then this problem has disappeared.

muyinliu commented 3 years ago

Still NOT work with git status with path contains Chinese characters. Reproduce with commands:

mkdir fpp-chinese-test
cd fpp-chinese-test
echo "test" > 测试.txt
git init
git status | fpp

=>

No lines matched!!

Note: fpp v0.9.2

Please reopen this issue.

Hanaasagi commented 3 years ago

@muyinliu @KapJI

It's actually a problem of using regex to match a filename that includes unicode. I see most regex are a-z.A-Z0-9. It will not match the unicode, only work with ASCII.

https://github.com/facebook/PathPicker/blob/e0d5cfc29ac67fcd1c0714275afdf0a80349d577/src/pathpicker/parse.py#L32

In Python3 \w can do this, but not all unicode.

\w

For Unicode (str) patterns:

    Matches Unicode word characters; this includes most characters that can be part of a word in any language, as well as numbers and the underscore. If the ASCII flag is used, only [a-zA-Z0-9_] is matched.

if change the regex to JUST_FILE = re.compile(r"([@%+\w\-_]+\.[a-zA-Z]{1,10})(\s|$|:)+"), it can match the file named 测试.txt.

Additionally, there is a filename-regex package in javascript. It uses more looser regex.

module.exports = function filenameRegex() {
  return /([^\\\/]+)$/;
};