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

Incorrect encoding (possiblely due to #505) #547

Closed
qiancy98 opened this issue Jun 7, 2024 · 6 comments
Closed

Incorrect encoding (possiblely due to #505) #547

qiancy98 opened this issue Jun 7, 2024 · 6 comments
Labels
contribution Thank you to the contributor! encoding implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix

Comments

@qiancy98
Copy link
Contributor

qiancy98 commented Jun 7, 2024

Please provide the following when posting an issue:

original .tex code

Please paste your .tex code here. Please note in answering your issue, I may add the code you provide to the test-cases directory. Please detail explicitly if you would prefer me not to do so..

yaml settings

encoding: GB2312
paths:

  • D:\Google 云端硬盘\资料\33 常用软件\其他脚本\安装\MiKTeX\latexindent.yaml

actual/given output

file D:\Google 锟狡讹拷硬锟斤拷\锟斤拷锟斤拷师锟斤拷锟斤拷锟斤拷\Hydra_QCY - partial (Edition 0821)\hydra-2 240525

INFO:  latexindent.pl version 3.24.1, 2024-05-12, a script to indent .tex files
       latexindent.pl lives here: C:/Users/qcy-5/AppData/Local/Programs/MiKTeX/scripts/latexindent/
       Fri Jun  7 22:53:27 2024
       Filename: d:/Google �ƶ�Ӳ��/����ʦ������/Hydra_QCY - partial (Edition 0821)/hydra-2 240525/__latexindent_temp_hydra2.tex
INFO:  Processing switches:
       -y|--yaml: YAML settings specified via command line
       -c|--cruft: cruft directory
INFO:  Directory for backup files and log file d:\Google �ƶ�Ӳ��\����ʦ������\Hydra_QCY - partial (Edition 0821)\hydra-2 240525\indent.log:
       d:\Google �ƶ�Ӳ��\����ʦ������\Hydra_QCY - partial (Edition 0821)\hydra-2 240525\
INFO:  Perl modules are being loaded from the following directories:
       C:/Strawberry/perl/lib/FindBin.pm
       C:/Strawberry/perl/vendor/lib/YAML/Tiny.pm
       C:/Strawberry/perl/lib/File/Copy.pm
       C:/Strawberry/perl/lib/File/Basename.pm
       C:/Strawberry/perl/lib/Getopt/Long.pm
       C:/Strawberry/perl/vendor/lib/File/HomeDir.pm
INFO:  LatexIndent perl modules are being loaded from, for example:
       C:/Users/qcy-5/AppData/Local/Programs/MiKTeX/scripts/latexindent/LatexIndent/Document.pm
INFO:  YAML settings read: defaultSettings.yaml
       Reading defaultSettings.yaml from C:/Users/qcy-5/AppData/Local/Programs/MiKTeX/scripts/latexindent/defaultSettings.yaml
INFO:  YAML reading settings
       The config file in "C:\Users\qcy-5/indentconfig.yaml" will be read
       Reading path information from C:\Users\qcy-5/indentconfig.yaml
       ---
       encoding: GB2312
       paths:
         - 'D:\Google 云端硬盘\资料\33 常用软件\其他脚本\安装\MiKTeX\latexindent.yaml'

INFO:  Encoding of the paths is GB2312
       Transform file encoding: D:\Google 云端硬盘\资料\33 常用软件\其他脚本\安装\MiKTeX\latexindent.yaml -> D:\Google ÔƶËÓ²ÅÌ\×ÊÁÏ\33 ³£ÓÃÈí¼þ\ÆäËû½Å±¾\°²×°\MiKTeX\latexindent.yaml
INFO:  YAML settings, reading from the following files:
       Reading USER settings from D:\Google ÔƶËÓ²ÅÌ\×ÊÁÏ\33 ³£ÓÃÈí¼þ\ÆäËû½Å±¾\°²×°\MiKTeX\latexindent.yaml
       ---
       indentAfterItems:
         case: '1'
       indentRules:
         item: \t
       lookForAlignDelims:
         align:
           alignDoubleBackSlash: '0'
           delims: '1'
           spacesBeforeAmpersand:
             leadingBlankColumn: '0'
         align*:
           alignDoubleBackSlash: '0'
           delims: '1'
           spacesBeforeAmpersand:
             leadingBlankColumn: '0'
         array:
           alignFinalDoubleBackSlash: '1'
           alignRowsWithoutMaxDelims: '0'
           delims: '1'
         bordermatrix: '1'
         bordmatrix: '1'
       modifyLineBreaks:
         environments:
           BeginStartsOnOwnLine: '1'
           BodyStartsOnOwnLine: '1'
           DBSFinishesWithLineBreak: '1'
           EndFinishesWithLineBreak: '1'
           EndStartsOnOwnLine: '1'
           equation*:
             BeginStartsOnOwnLine: '1'
             BodyStartsOnOwnLine: '1'
             EndFinishesWithLineBreak: '1'
             EndStartsOnOwnLine: '1'
         items:
           ItemStartsOnOwnLine: '1'
         mandatoryArguments:
           array:
             RCuBFinishesWithLineBreak: '1'
           bordermatrix:
             MandArgBodyStartsOnOwnLine: '1'
             RCuBFinishesWithLineBreak: '1'
             RCuBStartsOnOwnLine: '1'
           label:
             RCuBFinishesWithLineBreak: '1'
           tabular:
             RCuBFinishesWithLineBreak: '1'
         specialBeginEnd:
           displayMath:
             SpecialBeginStartsOnOwnLine: '1'
             SpecialBodyStartsOnOwnLine: '1'
             SpecialEndFinishesWithLineBreak: '1'
             SpecialEndStartsOnOwnLine: '1'
       verbatimEnvironments:
         tikzpicture: '1'

WARN:  modifyLineBreaks specified and m switch is *not* active
       perhaps you intended to call
            latexindent.pl -m -l D:\Google ÔƶËÓ²ÅÌ\×ÊÁÏ\33 ³£ÓÃÈí¼þ\ÆäËû½Å±¾\°²×°\MiKTeX\latexindent.yaml d:/Google �ƶ�Ӳ��/����ʦ������/Hydra_QCY - partial (Edition 0821)/hydra-2 240525/__latexindent_temp_hydra2.tex
INFO:  YAML settings read: -y switch
       YAML setting: defaultIndent:'\t'
       single-quoted string found in -y switch: '\t', substitute to 	
       Updating mainSettings with defaultIndent: 	
FATAL I couldn't find d:/Google �ƶ�Ӳ��/����ʦ������/Hydra_QCY - partial (Edition 0821)/hydra-2 240525/__latexindent_temp_hydra2.tex, are you sure it exists?
      Exiting, no indentation done.
       --------------
INFO:  Please direct all communication/issues to:
        https://github.com/cmhughes/latexindent.pl

desired or expected output

The file located in D:\Google 云端硬盘\吴老师的论文\Hydra_QCY - partial (Edition 0821)\hydra-2 240525\hydra2.tex being indented.

anything else

I am not sure if #505 breaks my program... (yesterday I found that my miktex packages was not updated since 2024/01, and after I updated my packages, the indent program breaks.)

Besides, this bug will not be reproduced on Ubuntu, as Ubuntu encodes everything in UTF-8, and windows encodes paths in GB2312.

@cmhughes cmhughes added the Help-wanted I'd like assistance with this issue, please! label Jun 8, 2024
@cmhughes
Copy link
Owner

cmhughes commented Jun 8, 2024

@fengzyf any ideas?

@cmhughes cmhughes added Help-wanted I'd like assistance with this issue, please! encoding and removed Help-wanted I'd like assistance with this issue, please! labels Jun 8, 2024
@fengzyf
Copy link
Contributor

fengzyf commented Jun 9, 2024

The latest commit 3d1f44d uses Win32:: GetACP() to retrieve the code page of the Windows system, thereby obtaining the system default encoding. Users do not need to specify the encoding.

@cmhughes cmhughes added implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix contribution Thank you to the contributor! and removed Help-wanted I'd like assistance with this issue, please! labels Jun 15, 2024
@cmhughes
Copy link
Owner

Implemented as of https://github.com/cmhughes/latexindent.pl/releases/tag/V3.24.2, thanks again to @fengzyf

@qiancy98
Copy link
Contributor Author

qiancy98 commented Sep 10, 2024

emmm It seems that there is still some bug...

console output (no log file is generated): (console is encoded with cp936, if this matters.)

PS D:\Google 云端硬盘\吴老师的论文\170821 Hydra2\hydra-2 240525> latexindent.exe -o out.tex hydra2.tex  
FATAL hydra2.tex exists, but could not open it
      Exiting, no indentation done.
PS D:\Google 云端硬盘\吴老师的论文\170821 Hydra2\hydra-2 240525> latexindent.exe -o out.tex "D:\Google 云端硬盘\吴老师的论文\170821 Hydra2\hydra-2 240525\hydra2.tex"
FATAL D:\Google 云端硬盘\吴老师的论文\170821 Hydra2\hydra-2 240525\hydra2.tex exists, but could not open it
      Exiting, no indentation done.

When path does not contain Chinese, it works. The file context is already encoded in UTF-8.


Possible bug analysis?

  • it seems that exist_with_encode($fileName) in FileExtension.pm:168 works, but open_with_encode( '<:encoding(UTF-8)', $fileName ) fails in FileExtension.pm:182.

@fengzyf
Copy link
Contributor

fengzyf commented Sep 10, 2024

@qiancy98 It works fine on my computer, please check whether the read permission of the file hydra2.tex is disabled
image

@qiancy98
Copy link
Contributor Author

@qiancy98 It works fine on my computer, please check whether the read permission of the file hydra2.tex is disabled image

Sorry, it seems that this is not problem of latexindent.tex.

In terminal.exe it works perfectly, but it fails in the terminal of VS Code (in Chinese: 直接在终端中运行命令的话, 运行正常. 但是在VS Code里的"集成终端"中不能正常运行.)

I will try to ask VS Code for this problem. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution Thank you to the contributor! encoding implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix
Projects
None yet
Development

No branches or pull requests

3 participants