I need to create a text file.
then to open it, using TextEdit.
Insert a text and save it.
all is well, except for the part where it says, it needed to be save as Unicode UTF-16.
so how can i make the new file as Unicode UTF-16 in the firs place.
You can do it yourself (add error trapping, adjust if needed, etc.):
set UnicodeText to the clipboard --> for example
set finalFile to choose file name default name "file.txt"
text2utf16(UnicodeText, finalFile)
to text2utf16(theText, outputFile)
set f to (open for access outputFile with write permission)
set eof of f to 0 --> empty file, just in case
--> the following two bytes mean this is a Unicode text file
write ((ASCII character 254) & (ASCII character 255)) to f
write theText to f as Unicode text starting at eof
close access f
end text2utf16