Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow preferring unzip over 7z, as it supports OEM encodings (#5) #396

Closed
wants to merge 1 commit into from
Closed

Conversation

alkisg
Copy link

@alkisg alkisg commented Jun 21, 2020

Hi, this PR addresses #5, i.e. it allows preferring unzip over 7z, because unzip supports OEM encodings and 7z doesn't and won't.

For example, if a Greek (or any non-English) user opens Windows explorer, right clicks on a folder and selects "Create .zip file", that .zip file can't be properly uncompressed with 7z, as it's using the OEM (DOS) encoding.

To tell unzip which OEM encoding was used, the user is expected to define the following environment variables:

export UNZIP="-O cp737"
export ZIPINFO="-O cp737"

Thus this patch checks if UNZIP is defined, and if so, it registers unzip before 7z.

@alkisg
Copy link
Author

alkisg commented Jun 21, 2020

Note for end users: one way to define these environment variables is to create a /usr/local/bin/engrampa file, with the following contents:

#!/bin/sh
# Set the correct OEM encoding for engrampa

export UNZIP="-O cp737"
export ZIPINFO="-O cp737"
exec /usr/bin/engrampa "$@"

Replace "cp737" with the appropriate DOS encoding for your country.

@sc0w
Copy link
Member

sc0w commented Jun 21, 2020

it doesn't work here, view -> last output says me zip files are opened with p7zip

anyway, in my point of view, the user must decide which prefer to use, gsettings key is needed

and unzip have issues opening files with password, see #279 (comment)

@alkisg
Copy link
Author

alkisg commented Jun 21, 2020

I'm attaching screenshots that prove that it works.
I used the win10test.zip file that I attached in #5 (comment).
The "before-patch" screenshot displays what non-English users see when opening windows-generated zip files. It's really important to give them at least a temporary way to open such files.
The "after-patch" screenshots shows the correct output.

Remember that to activate the patch AND to instruct unzip about the correct charset, you need to define the UNZIP environment variable. If you prefer to use a gsetting for this, then the users will have to toggle two things, both the gsetting and the environment variable, which would be very inconvenient.

So, for "after-patch", the command I used was:

UNZIP="-O cp737" ZIPINFO="-O cp737" engrampa win10test.zip 

before-patch

after-patch

@unxed
Copy link

unxed commented Jun 21, 2020

Why can not engrampa detect appropriate DOS encoding by system locale settings and set environment variables automatically?

@sc0w
Copy link
Member

sc0w commented Jun 21, 2020

we need to do the things easily to beginner users, if it needs additional steps before running engrampa, it is no good idea, engrampa must do the job itself in my opinion.

we need a way to detect the encoding (cp737) inside engrampa code

and add gsettings key to choose between unzip or p7zip

@alkisg
Copy link
Author

alkisg commented Jun 21, 2020

That would be a patch for unzip, not for engrampa. There have been various efforts for that for more than 10 years, but none of them became mainstream enough to reach the distributions. But the "-O charset" environment variables are supported.

We only ask from engrampa to allow us to prefer unzip, at least temporarily; engrampa code shouldn't bother with autodetecting encodings at all, as it's a huge task.

@alkisg
Copy link
Author

alkisg commented Jun 23, 2020

As mentioned in #5 (comment), I'm closing this PR as unxed's p7zip-based solution is much better.

@alkisg alkisg closed this Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants