kcrawford / dockutil

command line tool for managing dock items
http://patternbuffer.wordpress.com
Apache License 2.0
1.36k stars 131 forks source link

Unicode problem #98

Closed raistlin2912 closed 2 years ago

raistlin2912 commented 4 years ago

Same error issue #29, when doing add:

dockutil --add "/System/Applications/Music.app" --label "Música" --after "Fotos"

Result:

Traceback (most recent call last):
  File "/usr/local/bin/dockutil", line 669, in <module>
    main()
  File "/usr/local/bin/dockutil", line 371, in main
    commitPlist(pl, plist_path, restart_dock)
  File "/usr/local/bin/dockutil", line 658, in commitPlist
    writePlist(pl, plist_path)
  File "/usr/local/bin/dockutil", line 388, in writePlist
    plistlib.writePlist(pl, plist_import_path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 94, in writePlist
    writer.writeValue(rootObject)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue
    self.writeDict(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict
    self.writeValue(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 258, in writeValue
    self.writeArray(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 287, in writeArray
    self.writeValue(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue
    self.writeDict(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict
    self.writeValue(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 252, in writeValue
    self.writeDict(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 281, in writeDict
    self.writeValue(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 239, in writeValue
    self.simpleElement("string", value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 172, in simpleElement
    value = _escapeAndEncode(value)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 222, in _escapeAndEncode
    return text.encode("utf-8")             # encode as UTF-8
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

version: 2.0.5

shoopdawoop commented 3 years ago

Still having issues with unicode as well, e.g. with German localisation with Munki's 'Managed Software Center.app'; while adding works fine (as the English name) trying to find or remove the icon (once the localised string is recognised by the Dock) does not:

dockutil --find 'Geführte Softwareaktualisierung' or dockutil --find 'Gefu<0308>hrte Softwareaktualisierung'

results in

item Geführte Softwareaktualisierung was not found in /Users/user/Library/Preferences/com.apple.dock.plist

and

dockutil --remove 'Geführte Softwareaktualisierung'

throws a

/usr/local/bin/dockutil:317: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if pl[section][item_offset]['tile-data']['file-label'] == find_label:
Geführte Softwareaktualisierung was not found in /Users/user/Library/Preferences/com.apple.dock.plist
opus-nbonenberger commented 2 years ago

@kcrawford same problem here. German Umlauts are not working in labels.

Ü ü Ä ä Ö ä

Can you fix this, please?

kcrawford commented 2 years ago

I think this is working properly in dockutil 3. Please retest in dockutil 3.

opus-nbonenberger commented 2 years ago

I will wait until 3.0 is final. Thanks!

shoopdawoop commented 2 years ago

Tested and confirmed to work in macOS 12.2.1, including the formerly failing --find thank you!!1!

kcrawford commented 2 years ago

Thanks for testing! Closing this issue.