CocoaDev

Edit AllPages

Ok, so I’m trying to write some code to determine what text encoding was used to encode a certain text file. So When I open I call this message:

const General/ItemCount kMaxErrors= 10; const General/ItemCount kMaxFeatures= 100;

The problem, quite simply put, is that it doesn’t work. I always seem to get the same encoding from it. Some huge number I can’t for the life of me interpret. The second member of the returned regionEncodings array is always General/MacOSRoman too. I tried it with all sorts of different encodings and it doesn’t work. I would think Unicode would have been an easy one for it since it has the BOM, but no, not even that. Can someone shed some light on what I’m doing wrong? Or maybe point me to a working version of this? Unfortunately there is no tutorial or anything about Text Sniffers, just reference sentences on functions, so I’m kind of in the dark on this.