NSString dataUsingEncoding not working?

I can't get this to work:

    NSString *string = @"!#€%&/()*^*_:;;:;_poawolwasnndaw";
    NSData *stringData = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];

stringData will be nil. Why?

13.10.2009 16:15:26
1 ОТВЕТ
РЕШЕНИЕ

According to the documentation, setting allowLossyConversion:NO yields the following potential behavior:

Returns nil if flag is NO and the receiver can't be converted without losing some information (such as accents or case).

In this case, the Euro symbol above has no ASCII equivalent, so the entire result will come back nil.

5
13.10.2009 16:44:53