Click here to Skip to main content
15,907,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLink Problem Pin
Bernhard23-Jun-03 0:12
Bernhard23-Jun-03 0:12 
GeneralRe: Link Problem Pin
John M. Drescher23-Jun-03 0:32
John M. Drescher23-Jun-03 0:32 
Generaldetecting if a text file is ansi or unicode Pin
Jeremy Pullicino23-Jun-03 0:03
Jeremy Pullicino23-Jun-03 0:03 
GeneralRe: detecting if a text file is ansi or unicode Pin
Jonas Larsson23-Jun-03 0:57
Jonas Larsson23-Jun-03 0:57 
GeneralRe: detecting if a text file is ansi or unicode Pin
Johnny ²23-Jun-03 0:59
Johnny ²23-Jun-03 0:59 
GeneralRe: detecting if a text file is ansi or unicode Pin
Jeremy Pullicino23-Jun-03 1:43
Jeremy Pullicino23-Jun-03 1:43 
GeneralRe: detecting if a text file is ansi or unicode Pin
Johnny ²23-Jun-03 2:31
Johnny ²23-Jun-03 2:31 
GeneralRe: detecting if a text file is ansi or unicode Pin
RChin23-Jun-03 3:48
RChin23-Jun-03 3:48 
I also use the WinAPI function IsTextUnicode to test if a given text is unicode encoded or not.
There is no full proof detection method, also as pointed out by the reply below, it is HIGHLY recommended that all unicode text be prefixed by the 0xFEFF (or 0xFFFE) header to indicate the encoding. But this may not always be the case (for misbehaving progs).
The IsTextUnicode function, can then use a combination of statistical methods to give a probability estimate on the likely-hood of the given text being unicode.
I've used it in my programs and have had good results.
The best you could probably do is in addition to using these detection method, is to have a fallback in your program to force treating any known file as UNICODE or ANSI encoded.




"..Even my comments have bugs!"

Inspired by Toni78

GeneralRe: detecting if a text file is ansi or unicode Pin
Ryan Binns23-Jun-03 1:13
Ryan Binns23-Jun-03 1:13 
GeneralRe: Another Decision Pin
Jeremy Pullicino23-Jun-03 2:04
Jeremy Pullicino23-Jun-03 2:04 
GeneralRe: Another Decision Pin
Jeremy Pullicino23-Jun-03 3:57
Jeremy Pullicino23-Jun-03 3:57 
QuestionClassWizard missing classes? Pin
Mister Transistor22-Jun-03 23:39
Mister Transistor22-Jun-03 23:39 
AnswerRe: ClassWizard missing classes? Pin
John M. Drescher23-Jun-03 0:16
John M. Drescher23-Jun-03 0:16 
GeneralRe: ClassWizard missing classes? Pin
Mister Transistor23-Jun-03 0:50
Mister Transistor23-Jun-03 0:50 
QuestionGetDocument in a dialog? Pin
Mister Transistor22-Jun-03 23:35
Mister Transistor22-Jun-03 23:35 
AnswerRe: GetDocument in a dialog? Pin
will138323-Jun-03 2:41
will138323-Jun-03 2:41 
GeneralRe: GetDocument in a dialog? Pin
Mister Transistor23-Jun-03 4:09
Mister Transistor23-Jun-03 4:09 
AnswerRe: GetDocument in a dialog? Pin
David Crow23-Jun-03 2:43
David Crow23-Jun-03 2:43 
GeneralRe: GetDocument in a dialog? Pin
will138323-Jun-03 2:47
will138323-Jun-03 2:47 
GeneralRe: GetDocument in a dialog? Pin
Jonathan Craig23-Jun-03 3:40
Jonathan Craig23-Jun-03 3:40 
GeneralCoTaskMemAlloc vs. new Pin
peterchen22-Jun-03 23:26
peterchen22-Jun-03 23:26 
GeneralDrag and Drop Pin
Luke Murray22-Jun-03 22:45
Luke Murray22-Jun-03 22:45 
GeneralRe: Drag and Drop Pin
Luke Murray23-Jun-03 2:11
Luke Murray23-Jun-03 2:11 
GeneralThread Safety & Brute Force Locking Pin
aenima190622-Jun-03 22:14
aenima190622-Jun-03 22:14 
GeneralWindows API to check the presence of any NIC Pin
Hashim Saleem22-Jun-03 21:30
Hashim Saleem22-Jun-03 21:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.