Actually, I am using a data step to read the data from an input file. The file might contain special Unicode encoded data and I am handling it by using Encoding option of a FILENAME statement.
FILENAME nls ":\path\.txt" ENCODING="unicode";
This way, the program handles Unicode pretty well for Unicode saved files.
But I got myself caught in tricky situation when I learned that the input file could be saved using either Unicode as a encoding option or a normal ANSI. Hence first I got to check the type of the input file and then accordingly need to apply encoding option.
Just want to know if is there any file handling function by which we can determine the encoding option used to save the file so that we can use the corresponding encoding option later on.
Text files is basically a collection of undefined bytes, there are no built in logic that tells the user what encoding was used. To have that logic you will have to go for XML-files instead. So, the format of the text file is decided by the producer, and that knowledge could no be automated by the consumer (the SAS program), at least within SAS to my knowledge.
But I can't see this should be a problem. If you are building a SAS program to handle files, these files would not be created using a random encoding? You could be able to agree on an encoding in a file specification.