Weird text generation [writing text to file]

I am building a script to generate a simpleviewer xml file when an image is dropped into a folder. I thought I had it right. The text looks fine, however I discovered that it took to presses of the arrow key to move the cursor 1 character. I don’t know what to make of this. There seems to be some unexpected extra character between each intentional character in the text generated by my applescript. Any ideas? Here is the script:

on adding folder items to this_folder after receiving these_items
	tell application "Finder"
		activate
		set files_ to every file of this_folder
		set folderName to name of this_folder as text
		set names_ to ""
		repeat with file_ in files_
			set names_ to names_ & ("<image>" & return & tab & "<filename>" & (name of file_) & "</filename>" & return & tab & "<caption>" & (name of file_) & "</caption>" & return & "</image>" & return)
		end repeat
	end tell
	set opt to "<?xml version= \"1.0\" & encoding=\"UTF-8\" ?>
<simpleviewerGallery maxImageWidth = \"1600\" maxImageHeight = \"400\" textColor = \"0xffffff\" frameColor = \"0x111111\" frameWidth = \"1\" stagePadding = \"30\" thumbnailColumns = \"3\" thumbnailRows = \"1\" navPosition = \"bottom\" title = \"Title\" enableRightClickOpen = \"false\" backgroundImagePath = \"\" imagePath = \"\" thumbPath = \"\">" & return
	set close_ to "</simpleviewerGallery>"
	set f to ((path to desktop as text) & "gallery.xml")
	set nref to open for access file f with write permission
	set eof nref to 0
	write opt to file f
	write names_ to file f
	write close_ to file f
	close access nref
end adding folder items to

Model: MacBookPro
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Welcome. :slight_smile:

The data you write to the file needs to be in the proper encoding. If your want UTF-8 (that’s what you’re specifying in your XML declaration), then try writing the data as UTF-8.

write names_ to file f as «class utf8»

See also: A universal write_to_file routine

Thank you!

I knew I must be missing something.