Is Leopard Finder returning wrong Unicode for åÅ?
Is Leopard Finder returning wrong Unicode for åÅ?
- Subject: Is Leopard Finder returning wrong Unicode for åÅ?
- From: Håvard Graudo <email@hidden>
- Date: Mon, 7 Jan 2008 10:04:58 +0100
I am really confused about results I get with Leopard Finder with
filenames containing the very common Nordic letter 'å', capital 'Å':
Sometimes when getting a 'å' or 'Å' from Finder, I get very strange
results. Here is a sample script to demonstrate it. The error only
turns up in OS 10.5.
Håvard
-- A string containing the letter in question, and some other high-
ascii:
set aString to "test æøåÆØÅ test.txt"
-- make a file, name it with the string:
set MacHD to (path to shared documents from user domain) as string
set aDummyFile to MacHD & aString
set ggg to open for access file aDummyFile with write permission
write "nothing to see here" to ggg
close access ggg
-- use Finder to read the name of the newly created file:
tell application "Finder"
set aStringFromFinder to name of file aDummyFile
delete file aDummyFile
end tell
-- The two strings should be the same, and they seem so:
if aString = aStringFromFinder then display dialog "the strings are
identical"
-- checking the class for good measure:
log class of aString
log class of aStringFromFinder
--> both are (*text*). Script debugger: Unicode UTF-16
offset of "å" in aString
--> 8 (good!)
offset of "å" in aStringFromFinder
--> 8 (good!)
--> Now all the above is nice and dandy. Here is what really confuses
me:
--> Throwing the two seemingly identical strings at the same handler
gives two different results:
set fromString to my findChange(aString, "å", "X")
--> "test æøXÆØX test.txt" (good!)
set fromFinderString to my findChange(aStringFromFinder, "å", "X")
--> "test æøåÆØÅ test.txt" (DIFFERENT RESULT!! WHAT?)
--> How can this return a different result on OS 10.5?
--> On OS 9 -> 10.4 they return identical results. All other high-
ascii characters I have tested work, just not 'å' and 'Å'.
-- using ASTID to find/replace the text:
on findChange(txt, lookFor, changeTo)
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to lookFor
set nyTekst to text items of txt
set AppleScript's text item delimiters to changeTo
set nyTekst to nyTekst as text
set AppleScript's text item delimiters to oldDelims
return nyTekst
end findChange _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden