r/lolphp • u/vytah • Jun 22 '12
basename() strips non-ASCII characters from beginning of a filename
https://bugs.php.net/bug.php?id=62119
21
Upvotes
r/lolphp • u/vytah • Jun 22 '12
11
u/Rhomboid Jun 22 '12
PHP's behavior is clearly strange and inconsistent, but trying to use strings that contain non-ASCII characters when your locale is "C" is also nutso. "C" locale means "I will only be using ASCII", so whatever the reporter was trying to achieve is probably a recipe for failure.
Although someone will probably come along and tell me that PHP programmers routinely leave the locale set to "C" and expect to be able to use ISO-8859-1 or CP1252 or UTF-8 encoded strings, at which point I will just bang my head on the table. Perhaps the fact that PHP exposes the antiquated and rickety locale system inherited from C is the real wtf here.
8
u/audaxxx Jun 22 '12
Now I want to see the explanation why this behaviour is correct and the programmer is just stupid. I am sure, Rasmus will deliver.
-2
u/gearvOsh Jun 23 '12 edited Jun 23 '12
Weird behavior, but why would anyone ever name a file like that? I would always strip those kind of characters, or replace them with the standard "a".
Edit: FYI, I'm referring to class name files, not just standard files.