marekrei / encode-explorer

http://encode-explorer.siineiolekala.net
238 stars 120 forks source link

Non english filenames in windows apache #42

Open kofbox opened 8 years ago

kofbox commented 8 years ago

Hey. I tried to use this script in xampp on Windows. At the same time, I store files with names in different encodings. Encode Explorer does not correctly display these names.

On the Internet I found the solution here: http://php.net/manual/ru/function.urldecode.php (Comment by "alejandro at devenet dot net")

And here: https://www.w3.org/International/questions/qa-forms-utf-8.en

I made the appropriate changes in the code (very little) and now everything is working as it should in Windows.

Attached Encode Explorer with corrections. I would be glad if it will be accepted in the following versions of Encode Explorer. :)

index.txt

NewEraCracker commented 8 years ago

Hello,

Can you please test the changes I've made: https://github.com/NewEraCracker/encode-explorer/blob/feature/index.php

And let me know if they fix your problem?

Remember changing $_CONFIG['os_charset'] = "UTF-8"; to $_CONFIG['os_charset'] = "CP1251"; for it to behave correctly on your environment.

Also I'd appreciate you testing behavior with mbstring enabled and disabled, so that we can test both mbstring (mb_convert_encoding) and iconv conversion capabilities.

Regards.

kofbox commented 8 years ago

I tested. If you change the $ _CONFIG [ 'os charset'] = "CP1251" are all displayed correctly in the frontend. However, the links to files are not built correctly. On Windows, you need to link to the file built using iconv, but references to the folder were built as they are being built right now. All this is taken into account in a file that is embedded in my first post. Also see the screenshots. good not-good

NewEraCracker commented 8 years ago

I have changed the code slightly: https://github.com/marekrei/encode-explorer/pull/43/commits/f3c33dca25b6bd168e5ea49857f06c0636374278 Let me know if the problem is fixed now.

kofbox commented 8 years ago

Nope. Links to files still look like "http://domain.com/_video/%ED%E5%EF%F0%E8%EA%EE%F1%ED%EE%E2%E5%ED%ED%FB%E9%20%E7%E0%EF%E0%F1/%DD%E4%E4%E8%20%CC%B8%F0%F4%E8%201987.flv"

NewEraCracker commented 8 years ago

Try again please and let me know the outcome. I now keep href attribute as-is and only change the text that is shown.

Also made code more generic.

kofbox commented 8 years ago

Change your code at line 3183 to: print "\t\t<a href=\"".$this->location->getDir(false, true, false, 0, true).$file->getNameHtml(true)."\"";

and its be what we all want :)

havet commented 8 years ago

Hi, I've proposed an other solution using iconv: 1) On upload: // Konversion utf-8 > ISO. PT $name = iconv ("UTF-8", "ISO-8859-1", $name); //PT

2) On displaying the content: // Konversion ISO > UTF-8. PT $folder = iconv ("ISO-8859-1", "UTF-8", $folder); //PT print($folder); and // Konversion ISO > UTF-8. PT $fil = $file->getName(); // PT testar $fil = iconv ("ISO-8859-1", "UTF-8", $fil); // PT print $fil;

This works, but I don't know if this is the best way of doing it.

kofbox commented 8 years ago

havet, your method not working, after this code text shows like that:

àðãóìåíòîâ

NewEraCracker commented 8 years ago

Russian vs Swedish. Cyrillic vs Latin... ASCII is of many languages but only one at a time.

@havet: I think I found a transparent way of dealing with the usual encoding issues. Can you test the current code on my fork listing files (and directories) with Swedish filenames, while having set $_CONFIG['os_charset'] = "CP1252"; for your system.

I have done the change that @kofbox sugested. My best idea about why it is needed is because webserver uses UTF-8 winAPI instead of ASCII (unlike PHP).

Thank you both for your input and feedback! I want to tackle this weird encoding bugs to my best knowledge.

kofbox commented 8 years ago

NewEraCracker, also, if i set $_CONFIG['lang'] = "ru"; and save file index.php in UTF-8 codepage with BOM - some elements not showing. If without BOM - then all ok.

You may want to edit 11 line to:

  • NB!:If you change anything, save with UTF-8 without BOM! Otherwise you may
NewEraCracker commented 8 years ago

done.

Now waiting for further feedback and opinion of project owner.

xmodpt commented 8 years ago

hello all

grear job and i am loving it aldo i am have some problems with it.

in portugal we have some dif chars like " ç á à ã â " etc... In the index file all show's ok but the scan resaults that's where the problems begin. as you can see by the image, in the footer section of the frame the chars show's ok ( set $_CONFIG['lang'] = "pt_PT"; ) in the index file but when it scans the files, any file that have any special char it comes out as blank.

Any ideas ?

kind regards XmodPT

image

NewEraCracker commented 8 years ago

Boa tarde,

Usa a versão disponível aqui: https://github.com/NewEraCracker/encode-explorer e edita a seguinte linha $_CONFIG['os_charset'] = "UTF-8"; para $_CONFIG['os_charset'] = "CP1252";

Cumprimentos, Jorge Oliveira aka NewEraCracker

xmodpt commented 8 years ago

Boas tardes joao

Muito obrigado pela ajuda.

Bom fds

Nuno Pires

Em 11/09/2016 15:05, "Jorge Oliveira" notifications@github.com escreveu:

Boa tarde,

Usa a versão disponível aqui: https://github.com/ NewEraCracker/encode-explorer e edita a seguinte linha $_CONFIG['os_charset'] = "UTF-8"; para $_CONFIG['os_charset'] = "CP1252";

Cumprimentos, Jorge Oliveira aka NewEraCracker

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marekrei/encode-explorer/issues/42#issuecomment-246181956, or mute the thread https://github.com/notifications/unsubscribe-auth/AU--DtaGXcjvOSSE6ufmMBjN15LdGGxZks5qpAq3gaJpZM4H_cG3 .

xmodpt commented 8 years ago

Dear NewEraCracker

Thank you for all your help. Your sugestion worked like a charm.

Once again TY

Regards Nuno Pires AKA XmodPT

xmodpt commented 8 years ago

hello Jorge

Thank you for all the help but here i come again with another question:

Is there any way to "Force download" insted of opening in a new window ?

Thank you once more

regards

NP

2016-09-11 15:14 GMT+01:00 Nuno Pires xmodpt@gmail.com:

Boas tardes joao

Muito obrigado pela ajuda.

Bom fds

Nuno Pires

Em 11/09/2016 15:05, "Jorge Oliveira" notifications@github.com escreveu:

Boa tarde,

Usa a versão disponível aqui: https://github.com/NewEraCrack er/encode-explorer e edita a seguinte linha $_CONFIG['os_charset'] = "UTF-8"; para $_CONFIG['os_charset'] = "CP1252";

Cumprimentos, Jorge Oliveira aka NewEraCracker

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marekrei/encode-explorer/issues/42#issuecomment-246181956, or mute the thread https://github.com/notifications/unsubscribe-auth/AU--DtaGXcjvOSSE6ufmMBjN15LdGGxZks5qpAq3gaJpZM4H_cG3 .

xmodpt commented 8 years ago

second question:

is there a way to make the code detect if it is being opened on a cellphone so it automatically changes to "mobile" version ?

On 12 September 2016 at 22:13, Nuno Pires xmodpt@gmail.com wrote:

hello Jorge

Thank you for all the help but here i come again with another question:

Is there any way to "Force download" insted of opening in a new window ?

Thank you once more

regards

NP

2016-09-11 15:14 GMT+01:00 Nuno Pires xmodpt@gmail.com:

Boas tardes joao

Muito obrigado pela ajuda.

Bom fds

Nuno Pires

Em 11/09/2016 15:05, "Jorge Oliveira" notifications@github.com escreveu:

Boa tarde,

Usa a versão disponível aqui: https://github.com/NewEraCrack er/encode-explorer e edita a seguinte linha $_CONFIG['os_charset'] = "UTF-8"; para $_CONFIG['os_charset'] = "CP1252";

Cumprimentos, Jorge Oliveira aka NewEraCracker

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marekrei/encode-explorer/issues/42#issuecomment-246181956, or mute the thread https://github.com/notifications/unsubscribe-auth/AU--DtaGXcjvOSSE6ufmMBjN15LdGGxZks5qpAq3gaJpZM4H_cG3 .