A
A
Alexander Pankov2015-07-26 18:14:34
PHP
Alexander Pankov, 2015-07-26 18:14:34

Why cp1251 encoding when using glob function in php?

Hello.
Such a situation, I am trying to select the desired file from a folder (there are a lot of pictures in the folder) according to a specific template: for example

foreach (glob("/путь/тырыпыры_вес*.jpg") as $filename) {
    echo "$filename размер " . filesize($filename) . "\n";
}

But nothing came back, okay, I decided to see what would just return
foreach (glob("/путь/*.jpg") as $filename) {
    echo "$filename размер " . filesize($filename) . "\n";
}

iiii, he gave me all the pictures... BUT
all of them have rhombuses instead of Russian letters... (I guess - that's why the mask doesn't work)
select all the pictures, then apply iconv in UTF8 to each (each path), and then search by mask - somehow too wrong (although it works)
So the question is ... how can I make glob return immediately in normal encoding, and I could apply the mask and find only the files (paths) I need right there and then work with them .. (about 800 pictures in a folder)
Suspecting that I need to register something in php.ini, but I can't google what exactly..
Thank you in advance for your answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nazar Mokrinsky, 2015-07-26
@nazarpc

Because this is Windows, on Linux utf8 and everything is beautiful without crutches, otherwise you can’t do without converting characters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question