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

typeChar edge case #6

Open
ronzo99 opened this issue Jun 16, 2021 · 0 comments
Open

typeChar edge case #6

ronzo99 opened this issue Jun 16, 2021 · 0 comments

Comments

@ronzo99
Copy link

ronzo99 commented Jun 16, 2021

Finder has a "comment" property, which can be seen in Get Info for a folder, for example, or in SwiftAutomation:
print("comment: \"\(try finder.folders["TEMP"].comment.get())\"")

If there is a comment, the descriptorType is utxt and is printed correctly.
But if the comment is empty, the descriptorType is typeChar and SA prints
comment: "<ScalarDescriptor "TEXT" ...>"

One way to fix:
In unpackAsAny change
case typeUTF16ExternalRepresentation, typeUnicodeText:
to
case typeUTF16ExternalRepresentation, typeUnicodeText, typeChar:

Then, in unpackAsString add this case:

case typeChar:
	guard let result = String(data: descriptor.data, encoding: .macOSRoman) else { throw AppleEventError.corruptData }
	return result

NOTE: I'm running this on Mojave, so regarding the question posed in the comment on the above line,
"what, if any, macOS apps still use them", one answer is Finder (at least on Mojave 10.14.6).
NOTE: I have since confirmed that this is still the case on Big Sur 11.4

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

No branches or pull requests

1 participant