Search Results

Search found 1 results on 1 pages for 'danyowdee'.

Page 1/1 | 1 

  • Sane(r) way to get character-encoding of CLI?

    - by danyowdee
    Hi all! I was writing a CLI-Tool for Mac OS X (10.5+) that has to deal with command-line arguments which are very likely to contain non-ASCII characters. For further processing, I convert these arguments using +[NSString stringWithCString:encoding:]. My problem is, that I couldn't find good information on how to determine the character-encoding used by the shell in which said cli-tool is running in. What I came up with as a solution is the following: NSDictionary *environment = [[NSProcessInfo processInfo] environment]; NSString *ianaName = [[environment objectForKey:@"LANG"] pathExtension]; NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding( CFStringConvertIANACharSetNameToEncoding( (CFStringRef)ianaName ) ); NSString *someArgument = [NSString stringWithCString:argv[someIndex] encoding:encoding]; I find that a little crude, however -- which makes me think that I missed out something obvious...but what? Is there a saner/cleaner way of achieving essentially the same? Thanks in advance D

    Read the article

1