Can anybody explain why I get FEFE and not FEFF as BOM for utf16

Hello.

My first guess was that this is because a character doesn’t have a sign but, but when I actually checked the characters of the BOM I had BBEdit create for me when I saved as utf16 looks like this :“Ë›”“Ë›” (they are identical).

Here is the code I used to pull out the BOM of the file.


global tf, theNum
tell application "Finder"
	set fn to item 1 of (get selection) as alias
end tell
-- utf16test
set tf to open for access fn
set theNumStr1 to ASCII number of (read tf for 1 from 0) ”> 254
set theNumStr2 to ASCII number of (read tf for 1 from 1) ”> 254
close access tf
return

I found the material for this in the very good thread and this very good thread.

I guess the two bytes each with a value of 254 (FE) is rather unambiguous, but I’d still prefer FEFF as the real thing.

Best Regards

Mcusr

read for - from is 1-based

Now where is that emoticon, which hides its face behind its hands? :cool:

If found this post of general interest today by the way: it describes how the copy command works like a closure, it doesn’ only copy downwards, it copies upwards too. (The run time environment).

Best Regards

McUsr