-
Notifications
You must be signed in to change notification settings - Fork 11
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
diacritic characters does truncated #20
Comments
Hi, thanks for interesting issue.
Can you check diacritic_characters branch with possible fix? |
c:\Work\OpenSource\pylnk\diacritic_characters>c:\python\x64\310\python
Python 3.10.1 (heads/3.10.1-win7:830a41fd9d, Dec 12 2021, 11:29:02) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylnk3
>>> lnk = pylnk3.Lnk('d:\\1.txt.lnk')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Work\OpenSource\pylnk\diacritic_characters\pylnk3.py", line 1504, in __init__
self._parse_lnk_file(f)
File "c:\Work\OpenSource\pylnk\diacritic_characters\pylnk3.py", line 1555, in _parse_lnk_file
self._link_info = LinkInfo(lnk, unicode=self.link_flags.IsUnicode)
File "c:\Work\OpenSource\pylnk\diacritic_characters\pylnk3.py", line 994, in __init__
self._parse_path_elements(lnk)
File "c:\Work\OpenSource\pylnk\diacritic_characters\pylnk3.py", line 1026, in _parse_path_elements
self.local_base_path = read_cstring(lnk, encoding=self.encoding)
File "c:\Work\OpenSource\pylnk\diacritic_characters\pylnk3.py", line 186, in read_cstring
return s.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 3: invalid start byte I've just created |
Can you share broken lnk file? Can't reproduce myself. |
I suspect there is some other format than utf-8. By the way the |
it's |
How did you find that? There is at least 3 code pages which has no difference: 1250, 1257, 1258.
You can create the |
Just guesses. It's default for english Windows. And it's decodes path correctly. |
Does there exist instructions how to build executable in the Scripts? |
Can you add the same fix as in another link parser repository? |
Another solution here is that. If try to use {
"relative_path": ".\\\u00f6\u00f6\u00f6\\1.txt",
"work_dir": "D:\\\u00f6\u00f6\u00f6",
"link_info": {
"local_base_path": "D:\\\u0446\u0446\u0446\\1.txt"
},
} It does print correct characters in case of |
As noted here: https://stackoverflow.com/questions/39365489/how-do-you-keep-diacritics-in-shortcut-paths
The
WScript.Shell
implementation does not support diacritic characters in an Unicode string in case ofTargetPath
shortcut property. But this module has the same issue:c:\1.txt.lnk
->c:\ööö\1.txt
>pylnk p c:\1.txt.lnk _link_info._path
But
WorkingDirectory
property is not affected:>pylnk p c:\1.txt.lnk _work_dir
I've compared with https://github.com/Matmaus/LnkParse3 implementation and it returns more reliable results:
>lnkparse c:\1.txt.lnk
When
pylnk3
is not:>pylnk3 p c:\1.txt.lnk _link_info.local_base_path
I've tried to change the code:
But it still returns a truncated variant. Seems the app does read only one property field (Ansi) instead of 2 (Ansi+Unicode) as
LnkParse3
does.The text was updated successfully, but these errors were encountered: