1

I'm having several problems filtering the name of a file upload. About spaces I'm using trim() function, and also dropping special characters like quotes and #.

But I sometimes find filenames with non alphabetical characters like Chinesse, Arabic and Polish. I would like to know if there's a function able to drop this characters, only keeping the roman alphabet ones.

Thanks in advance.

I tried using str_replace() function but I couldn't find a way to keep all symbols and acentuated letters.

mitebu
  • 23
  • 4
  • 1
    Why do you want to do this? Surely you can allow anything which is a valid character for a filename in the operating system where you want to save the file? – ADyson Oct 26 '22 at 07:52
  • @ADyson in my application I upload a lot of documents (most of them datasheets and bills) and the filename usually contains chinesse letters, that's why I would like to replace them, because in some environments, this letters aren't read properly. – mitebu Oct 26 '22 at 11:17
  • What environments are those? Maybe try fixing the environments – ADyson Oct 26 '22 at 11:40
  • I have a feeling for sure someone else has tried to get rid of non-roman letters from a string, surely there's something on the internet you can use, maybe for example [this](https://stackoverflow.com/questions/22520932/python-remove-all-non-alphabet-chars-from-string) – Matthias Oct 26 '22 at 12:47

0 Answers0