Character Encoding from Applescript to Filemaker

I have an Applescript that reads a library provided RIS file (.ris). Using Applescript, Info for the RIS file contains the following

kind:“TextEdit Document”, file type:“”

I assumed that this would be a simple text file. However, just now when I pasted in the line immediately above it came out as

kind:“TextEdit Document”, file type:"

Hi,

more interesting than file type (obsolete) and kind is the type identifier. TextEdit documents can be plain text (.txt) or rich text (.rtf). The kind is the same, the type identifier is different.

Oops! There are four null characters in between the double quotes for “file type:”. That resulted in my message being cutoff at that point. So, I will try to rebuild it all here using spaces for the null characters.

I have an Applescript that reads a library provided RIS file (.ris). Using Applescript, Info for the RIS file contains the following

kind:“TextEdit Document”, file type:“”

I assumed that this would be a simple text file. However, just now when I pasted in the line immediately above it came out as

kind:“TextEdit Document”, file type:" "

The four characters within the quotes of “file type:” are ascii 0’s or four null characters.

Here is the issue–

The Applescript reads in the RIS file correctly, the material is processed, and then it is output to Filemaker. The text that Applescript has placed in Filemaker behaves strangely. When I change the capitalization of a character within Filemaker using Filemaker’s ability to change case, the capitalization change looks fine in Filemaker. However, when that altered material is fed to the web, the capitalization change does not appear in a browser. If the character is retyped in Filemaker to effect the capitalization change, it does appear correctly in a browser.

When I first implemented the Applescript, the RIS file was read by TextEdit, then this material was copied to the clipboard, processing occured, and it was sent to Filemaker. There were no such problems with capitalization as there is now.

My suspicion is that it has something to do with text encoding. Here is the routine that reads in the RIS file:


on GetRISfileContents(aFile)
	open for access aFile
	set fileContents to (read aFile)
	close access aFile
	return fileContents
end GetRISfileContents

Any assistance would be greatly appreciated.
:rolleyes:

The AppleScript read command reads text files with MacRoman encoding by default.
You have to figure out what text encoding is used in the file.

For UTF-8 you have to write

set fileContents to (read aFile as «class utf8»)

For UTF-16

set fileContents to (read aFile as Unicode text)

Any other text encoding is not supported.

The open for access and close access lines are not needed for a simple read operation.

Thank you StefanK! That did the trick!

Best wishes,
Haole Surfer Dude