Skip to content

typeChar edge case #6

@ronzo99

Description

@ronzo99

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions