Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C How to list all available encoding

In Java I can get all the available encodings with this code:

SortedMap<String, Charset> availableCharsets = Charset.availableCharsets();
Vector allEncodes = new Vector();
for (Map.Entry<String, Charset> entry : availableCharsets.entrySet()) {
            allEncodes.add(entry.getKey());
}

Then, I can read any file with any encode I want:

Reader in = new InputStreamReader(new FileInputStream(aPath), allEncodes.get(0) );

So, is there any idea how to implement this in Objective-C

like image 440
Hizabr Avatar asked Oct 06 '22 15:10

Hizabr


1 Answers

const NSStringEncoding* encodingArray = [NSString availableStringEncodings];

like image 133
JWWalker Avatar answered Oct 10 '22 01:10

JWWalker