Giter Site home page Giter Site logo

Comments (10)

bitcookies avatar bitcookies commented on August 27, 2024

是的,但主要还是 ANSI 编码的问题。ANSI 在不同国家和地区有不同的标准,如 GB2312(**)、JIS(日本)等,不同 ANSI 编码之间互不兼容。Powershell 7.4 之前的版本还不能支持 ANSI 编码,所以先用 ASCII 代替。

当然对于 ANSI 编码而言,0x00~0x7F 之间的字符,依旧是1个字节代表1个字符。ASCII 字符集是与 ANSI 字符集中的前面128个(即 0-127)字符相同。这一点也是 ASNI 编码与 Unicode 编码之间最大也最明显的区别。

参考:

所以多语言的支持可以如下生成(utf8 与 utf8BOM 均可),例如:

.\winrar-keygen.exe "简体中文" "Github.com" | Out-File -Encoding utf8 rarreg.key

.\winrar-keygen.exe "繁體中文" "Github.com" | Out-File -Encoding utf8 rarreg.key

.\winrar-keygen.exe "Deutsch" "Github.com" | Out-File -Encoding utf8 rarreg.key

.\winrar-keygen.exe "Français" "Github.com" | Out-File -Encoding utf8 rarreg.key

.\winrar-keygen.exe "日本語" "Github.com" | Out-File -Encoding utf8 rarreg.key

.\winrar-keygen.exe "한국어" "Github.com" | Out-File -Encoding utf8 rarreg.key

当然,生成后需要手动将 rarreg.key 文件以 ANSI 格式重新保存。

Powershell 支持 ANSI 编码要等到 7.4

  • ansi: Uses the encoding for the for the current culture's ANSI code page. This option was added in PowerShell 7.4.

Powershell 需要在 7.4 版本之后才能使用 ANSI 编码,例如生成您的 license 可采用如下命令:

.\winrar-keygen.exe "神北小毬" "Single PC usage license" | Out-File -Encoding ansi rarreg.key

对于现在 7.4 之前版本的 Powershell,暂时采用如下命令:

.\winrar-keygen.exe "神北小毬" "Single PC usage license" | Out-File -Encoding utf8 rarreg.key

然后,手动将生成的 rarreg.key 文件以 ANSI 格式重新保存,rarreg[神北小毬新生成].zip

参考:https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file?view=powershell-7.4

安装 Powershell 7.4

当前 Winget Microsoft.PowerShell 版本为 7.3.7,但是 Microsoft.PowerShell.Preview 预览版已经更新到 7.4.x,多语言支持还需稍等一段时间,不过已经可以排上日程了 😀

参考:使用 Winget 安装 PowerShell(推荐)

from winrar-keygen.

lsflling avatar lsflling commented on August 27, 2024

使用ANSI编码的话直接生成就可以使用了。
但是官方给的是utf-8编码的rarreg.key文件。
以下是utf-8编码的授权文件和ANSI编码的授权文件在日语系统日语WinRAR下的显示体现。
Snipaste_2024-05-13_17-45-24
Snipaste_2024-05-13_17-46-30

from winrar-keygen.

bitcookies avatar bitcookies commented on August 27, 2024

这么看来应该是拿 UserName 的 local ansi 的值去做参数了,从图片来看可能是:

gbk JIS
神北小毬 ノアミ。堋

from winrar-keygen.

lsflling avatar lsflling commented on August 27, 2024

不是。一个是utf-8编码,在日语系统中文字显示正常。一个是GB2312编码,在日语系统中按照Shift JIS显示了。

from winrar-keygen.

bitcookies avatar bitcookies commented on August 27, 2024

后者对应的是图1,前者对应的是图2?

from winrar-keygen.

lsflling avatar lsflling commented on August 27, 2024

显示为[神北小毬]的rarreg.key文件为UTF-8编码,显示为[乱码]的rarreg.key文件为GB2312编码。
显示为[神北小毬]的rarreg.key文件第二行为utf8:神北小毬,显示为[乱码]的rarreg.key文件第二行为神北小毬。

from winrar-keygen.

bitcookies avatar bitcookies commented on August 27, 2024

哦那就是用了 utf8 编码生成。在 Windows 应用中使用 UTF-8 代码页,或者对 WinRarKeygen.hpp 中 lpszUserNamelpszLicenseType 加之编码处理即可。utf8: 不仅作为 winrar license 的编码声明,同时也参与 key generation

from winrar-keygen.

bitcookies avatar bitcookies commented on August 27, 2024

更新添加了对 utf-8 编码的支持

from winrar-keygen.

lsflling avatar lsflling commented on August 27, 2024

我安装了Powershell 7.4.2,在PROFILE设置了UTF-8编码($OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding)。
运行echo "utf8:**" > codecheck.txt得到的文件是UTF-8 no BOM的文件。
但是运行:.\winrar-keygen-x64.exe "utf8:**" "Single PC usage license" > rarreg.key 得到的文件依然是GB2312编码。

from winrar-keygen.

bitcookies avatar bitcookies commented on August 27, 2024

事实上 Windows 中的文本文件没有格式,Windows 根本不会自行跟踪文本文件的编码,所以也无法可靠地检测文本文件中的编码(可以做的就是通过搜索非 ascii 字符并尝试与 Unicode 组合来进行有根据的猜测)[1]。

有一个非官方的约定,如果文件以 UTF-8 with BOM 开头,则它是 UTF-8,但该约定并未得到普遍支持。所以即使同为 UTF-8 的文本文件也常常会有不同的头部编码;即使文本文件的十六进制编码开头为 EF BB BF,也不能表示它们是 UTF-8 编码的文件 [2]。

[System.IO.File]::ReadAllBytes(".\codecheck.txt")

实际上 keygen 仍是按照 ANSI 编码(ASCII + Windows 所设置国家或地区的编码)方式运行,以下配置仅是让 pwsh 能够以 UTF-8 编码处理输入和输出。要让程序本身以 UTF-8 编码运行,须 Windows 设置 Unicode UTF-8 提供全球语言支持 [4]。

$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

参考:

  1. https://stackoverflow.com/a/4255455/10242225
  2. https://stackoverflow.com/a/6947841/10242225
  3. https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
  4. https://stackoverflow.com/a/57134096/10242225

from winrar-keygen.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.