Re: Unicode to plain text
Re: Unicode to plain text
- Subject: Re: Unicode to plain text
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 20 Sep 2002 16:51:52 -0700
On 9/20/02 3:39 PM, "John Delacour" <email@hidden> wrote:
>
At 2:34 pm -0700 20/9/02, Paul Berkowitz wrote:
>
>
> So the Finder is meant to be doing exactly what TextEdit does. But
>
> AppleScript gives us the "styled text" stuff for Finder file and folder
>
> names, but JD got "real Unicode" out of TextEdit, at least when entered in
>
> his specified manner.
>
>
In a word, the Mac understands Unicode fine and uses it, just as
>
WinNT understands Unicode and uses it, but most things on the Mac and
>
most things on a PC don't know how to render it. In general MS apps
>
in WinNT+ are OK with Unicode -- not yet MS stuff for the Mac.
>
>
For say 15000 Han characters, there exist equivalents in the old
>
Big5, GB or JIS character sets, and these can be displayed in any
>
application after conversion, but there are many Han characters in
>
Unicode that cannot be so displayed, and the Lao characters I used
>
earlier as an example, or the polytonic Greek characters, equally
>
exist in no 'legacy' charset and cannot be displayed in the outdated
>
apps that still abound on our machines at this early stage in the new
>
era. The Mac sees everything as Unicode and it helps dim-witted
>
programs like Script Editor to find the nearest equivalent IF it
>
exists, so if I name a file [greek small letter alpha with psili]
>
(0x1F00), then Script Editor will be told to find a small alpha --
>
which it finds in the Japanese Osaka font -- and to draw an
>
apostrophe after the alpha as an approximation of the psili, which
>
would be drawn properly as a diacritic above the character.
>
>
The Finder will display file names in proper Unicode and not as styled text.
>
>
Does that make things any clearer?
Partially, but not completely. I'm not talking about a script editor's
display.
If pick a file on my desktop, change my Keyboard menu to Japanese, and type
in a number of Japanese characters to rename it, then do this:
tell application "Finder"
set theName to name of item 1 of (get selection)
end tell
set plainName to ((theName as record)'s <<class ktxt>>)
it does not error. Instead it gives me nonsense as the result. If I step
through it in Script Debugger, I get a result for the first line which must
be "approximating" theName to a styled text version of the real Unicode
Finder name, even though I'm not asking for it to be displayed or rendered
anywhere. If I do:
tell application "Finder"
set theName to name of item 1 of (get selection)
end tell
set f to "" & (path to temporary items) & "japanese.txt"
open for access file f with write permission
set eof file f to 0
write ((ASCII character 254) & (ASCII character 255)) to file f
write theName to file f
close access file f
tell application "Finder"
open file f using application file id "com.apple.textedit"
end tell
tell application "TextEdit"
set uText to get paragraph 1 of document 1
end tell
class of uText
try
uText as record
on error e
return {uText, e}
end try
Now this does _not_ error. TextEdit is displaying the identical Japanese
characters (these are complex ideographs, not the ones they use for Western
words) with no munging. The true Finder Unicode has been transferred to
TextEdit. But this time AppleScript made a styled text version of it,
presumably in the very first line.
Does this not indicate that AppleScript, not the various script editors and
their poor rendering text engines, is presently coercing true Unicode to
what you referred to as 'styled text mish mash', somewhere along the line?
Even if I have been lucky in finding a quite long series of characters which
display correctly in this styled text version, at what point is the real
Unicode text being coerced to this styled text, and why?
Perhaps you should give a file a polytonic Greek name and see what happens
to it, doing the same as the above?
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.