What a saga…
So it turns out that stringWithContentsOfFile_encoding_error_ reads the file (sort of) OK, but initWithData_encoding_ has no luck, even though you’d expect them to do the same thing.
It looks like the file has mixed encoding: the first line was saved as MacRoman text, and the rest as Unicode (I suspect courtesy of the madness of the write command at one time). Whatever, initWithData_encoding_ gives up where the encoding changes.
Surprisingly, this (sort of) works:
set theString to current application's NSString's alloc()'s initWithData_usedEncoding_(dataFromDocument, reference)
I say “surprisingly” because no such method is listed. But it seems to be an undocumented analog to stringWithContentsOfFile_usedEncoding_. (The latter claims UTF8 encoding in this case, which isn’t correct).
Anyway, the only reliable way I can see is to split the data. And in fact if the first line doesn’t matter, which I suspect is the case, you can just skip it, and decode the rest, which is – for yet another wrinkle – NSUTF16LittleEndianStringEncoding. So:
set aBit to dataFromDocument's subdataWithRange_({19, (dataFromDocument's |length|() as integer) - 20})
set theString to current application's NSString's alloc()'s initWithData_encoding_(aBit, current application's NSUTF16LittleEndianStringEncoding)
log theString
Even then there’s an odd character or two in the Path in the file.
If you really needed it, I’d advise replacing readFromData_ofType_error_ in your app, as mentioned earlier.