Re: Words of Bug in Leopard (Japanese environment)
Re: Words of Bug in Leopard (Japanese environment)
- Subject: Re: Words of Bug in Leopard (Japanese environment)
- From: Christopher Nebel <email@hidden>
- Date: Tue, 5 Aug 2008 23:20:43 -0700
On Aug 5, 2008, at 9:39 PM, Takaaki Naganoya wrote:
I tryed to get MAC address from en0 in Japanese environment.
<AppleScript>
set aMacAdrStr to (do shell script "ifconfig en0 | grep 'ether'")
set aW to words of aMacAdrStr
</AppleScript>
In Tiger, the result was reasonable.
<result in Tiger (10.4.11 + MacBook Pro 2.0GHz)+ Japanese User
Environment>
--> {"ether", "00", "1e", "c2", "01", "45", "bf"}
</result in Tiger>
But.. in Leopard....
<result in Leopard (10.5.4+ MacBook Pro 2.4GHz)+ Japanese User
Environment>
--> {"ether", "00", "1e:c2", "01", "45", "bf"}
</result in Leopard>
I could not believe my eyes...
<AppleScript>
words of "1e:c2"
</AppleScript>
This causes unexpected result. In English user environment, the
result was normal.
I have same test with some east asian language environment...
Chinese (Simple Chinese): Wrong
Hangul : Wrong
AppleScript just does what the international word break rules say.
You could file a bug against them -- I think this particular case
involves the treatment of ":" in Swedish and Finnish; they use it much
like English uses apostrophe -- but I'll remind you of this bit from
the revised AppleScript Language Guide:
"word: A continuous series of characters, with word elements parsed
according to the word-break rules set in the International preference
pane. Because the rules for parsing words are thus under user
control, your scripts should not count on a deterministic text parsing
of words."
Basically, don't use "word" elements to process anything other than
natural language text. In your case, you probably want text items
breaking on ":". Alternatively, you could set your word break
preference (System Preferences > International > Language > Word
break) to "English (United States, Computer)", which always treats ":"
as a word break, but that would probably do horrible things to your
Japanese word breaking.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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