How can I get the Console to display "can’t" instead of "canÕt"?
4
votes
1
answer
196
views
It's only a small thing I guess, but I'm annoyed to see errors reported in the console for my AppleScripts where the text of the error message contains substitute characters. e.g.
Error Number: -43 Error Message: The operation canÕt be completed.
In the error message "can’t" has been replaced by "canÕt"
I’m not sure if this is a failure of AppleScript, the shell or console.app.
I've tried the usual routes of examining console.app (no settings), System Settings (language & regions and keyboard characters seems not to affect console output).
This example demonstrates the problem:
set appName to "textTester"
set targetFolder to "Virtuality:Users:minmin:Documents:" -- an non-existent destination forces the error
try
tell application "System Events"
set theResult to name of every file of targetFolder
end tell
on error errMsg number errNum
set logEntry to (linefeed & errNum & space & errMsg & linefeed) as text
tell me to writeToLogFile(logEntry, appName) -- error messages generated by AppleScript itself create the problem
tell me to writeToLogFile("Who would've thought I can't log this text properly?", appName) -- demonstrates that writing directly to the log is fine
end try
on writeToLogFile(logEntry, appName)
local handlerName
set handlerName to "writeToLogFile"
set theDate to do shell script "date '+_%Y_%m_%d'"
set theDate1st to do shell script "date '+_%Y_%m'" --real date 1st would be "date '+_%m_1_%Y'"
set libPath to path to library folder from user domain as string
set theFolderPath to (libPath & "Logs:") as string
set theFilePath to (theFolderPath & appName & ":") as string
set theFileName to (appName & theDate1st & ".log")
set theFile to (theFilePath & theFileName)
try
set okToContinue to false
tell application "Finder"
--make sure the folder is there
if (not (exists folder theFilePath)) then
make new folder at theFolderPath with properties {name:appName}
end if
--make sure the logfile is there - or turn it over
if (not (exists theFile)) then
set theFile to make new file at theFilePath with properties {name:theFileName, file type:"TEXT", creator type:"ttxt"}
end if
--open and write logfile entries
set theFile to theFile as alias
tell me
set writetoTheThing to open for access theFile with write permission
write (logEntry & return) to writetoTheThing starting at eof
close access (writetoTheThing)
end tell
set okToContinue to true
end tell
on error errMsg number errNum
log errMsg
end try
return okToContinue
end writeToLogFile
Is there indeed a fix?
Asked by softlee
(43 rep)
Jun 14, 2024, 07:28 AM
Last activity: Feb 12, 2025, 12:56 AM
Last activity: Feb 12, 2025, 12:56 AM