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

set WebClient encoding to UTF-8 explicitly #2577

Closed

Conversation

yukihane
Copy link
Contributor

@yukihane yukihane commented Sep 9, 2018

@r15ch13
Copy link
Member

r15ch13 commented Sep 9, 2018

Does this work on a Japanese Windows? Downloading works, but extraction still fails:

λ .\bin\scoop.ps1 install https://raw.githubusercontent.com/yukihane/scoop-bucket-yukihane-games/91d960886de11fc41137918394b9de2f943da616/densya.json
WARN  Scoop uses 'aria2c' for multi-connection downloads.
WARN  Should it cause issues, run 'scoop config aria2-enabled false' to disable it.
Installing 'densya' (1.06) [64bit]
Loading dcnt.cgi from cache.
Checking hash of dcnt.cgi ... ok.
Extracting densya.zip ... DEBUG
-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : Sonntag, 9. September 2018 14:06:29
   Source : D:\scoop\apps\densya\1.06\_tmp\????\
     Dest : D:\scoop\apps\densya\1.06\

    Files : *.*

  Options : *.* /S /E /DCOPY:DA /COPY:DAT /MOVE /R:1000000 /W:30

------------------------------------------------------------------------------

2018/09/09 14:06:29 ERROR 2 (0x00000002) Accessing Source Directory D:\scoop\apps\densya\1.06\_tmp\????\
The system cannot find the file specified.

ERROR Could not find 'デンシャ'! (error 16)
Please contact the bucket maintainer!

image

@yukihane
Copy link
Contributor Author

yukihane commented Sep 10, 2018

I guess it is another issue, depends on zip file name encoding.
These directory/file names are shift-jis(cp932) encoded, so needed entryNameEncoding explicitly on non shift-jis environment.

diff --git a/lib/core.ps1 b/lib/core.ps1
index 505ffefb..b99ce0d9 100644
--- a/lib/core.ps1
+++ b/lib/core.ps1
@@ -264,7 +264,7 @@ function unzip($path, $to) {
     }

     try {
-        [io.compression.zipfile]::extracttodirectory($path,$to)
+        [io.compression.zipfile]::extracttodirectory($path,$to,[System.Text.Encoding]::GetEncoding("shift-jis"))
     } catch [system.io.pathtoolongexception] {
         # try to fall back to 7zip if path is too long
         if(7zip_installed) {

About this problem: https://marcosc.com/2008/12/zip-files-and-encoding-i-hate-you/


I found one more issue.
WScript#CreateShortcut supports only host codepage.
When run my manifest on English version Windows(cp437), following error occurs:

PS C:\Users\Administrator\scoop\apps\scoop\current> .\bin\scoop.ps1 install https://raw.githubusercontent.com/yukihane/s
coop-bucket-yukihane-games/91d960886de11fc41137918394b9de2f943da616/densya.json
Installing 'densya' (1.06) [64bit]
Loading dcnt.cgi from cache
Checking hash of dcnt.cgi ... ok.
Extracting densya.zip ... done.
Running pre-install script...
Linking ~\scoop\apps\densya\current => ~\scoop\apps\densya\1.06
Creating shim for 'densya'.
Unable to save shortcut "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Scoop
Apps\????.lnk".
At C:\Users\Administrator\scoop\apps\scoop\current\lib\shortcuts.ps1:56 char:5
+     $wsShell.Save()
+     ~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException

Creating shortcut for デンシャ (Game.exe)
Persisting Game.ini
Persisting Save
'densya' (1.06) was installed successfully!

I found a solution using C#, but I can not understand this code ...:
https://stackoverflow.com/questions/13542005/create-shortcut-with-unicode-character

@yukihane
Copy link
Contributor Author

I have divided issue, #2584 and #2585 , because #2573 is different from theirs.
This pull request #2577 fixes #2573 only.

@rashil2000
Copy link
Member

Superceded by #4912

@rashil2000 rashil2000 closed this May 9, 2022
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