Link to home
Start Free TrialLog in
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)Flag for United States of America

asked on

Detect if a text file contains single-byte or unicode.

I need to detect whether or not a text file contains unicode text or single-byte text. After a little research I suspect it might be something as simple as counting the number of high ASCII characters and, if more than some small number, assume the file is unicode. Is there a better way? Is there an API call to detect the type of text in a string or byte array?

Kevin
ASKER CERTIFIED SOLUTION
Avatar of mvidas
mvidas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zorvek (Kevin Jones)

ASKER

Sorry...not done yet. I am still trying to get the code from egl1044 to function correctly. I'll be posting more comments soon seeking additional assistance with this.

Kevin
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I still have not had time to get this to work. My tests thus far have proven that it does not work but I do not yet have enough information to post follow-up information/questions. As none of the above answers have been proven to work I can therefore not allow any of them to be selected as an answer as that will provide false information to future viewers of this question. I also do not have the time right now, not the appropriate Windows installations, to fully test the above scenarios or any derivatives of such.

I therefore ask that the question either be left alone for the time being or deleted. If deleted I will repost at a later date with as much of the information above as is relevant.

Remember that being a responsible EE member is not just maintaining questions, it's making sure the EE database provides good information to future viewers.

Kevin
I have not been able to get any of the above solutions to work yet. But I am confident an answer does lie somewhere above. The problem I have is the machine I need to test these potential solutions is only occasionally available to me and I am being pulled in other directions. I, like you, like a clean TA and try to encourage askers to clean up sooner versus later. But I also appreciate the occasional difficult situation and the need to add good content to the database.

So, for the record, I am confident that an answer to this problem lies above. However, I have been unable to get any of the above answers to work reliably. By closing the question I will be unable to post additional information after one week so the final correct answer will remain a challenge for any who follow.

Since you have forced my hand (I don't want the above information deleted) I'm going to mark all of the answers above as correct and you, Mr. Rollins, can live with the fact that the database now has one more incomplete thread.

Kevin