• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best encoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best encoding


  • Subject: Re: Best encoding
  • From: Lorenzo <email@hidden>
  • Date: Fri, 08 Jul 2005 16:10:57 +0200

GREAT !!!!
It worked like a charm. I write here just a brief for the Coca list and for
the memories. Suppose that strEncoding read is ISO-8859-1 (I assign it here
by myself).

    strEncoding = @"ISO-8859-1";   NSLog(@"strEncoding %@", strEncoding);

    CFStringEncoding cfEncoding;
    NSStringEncoding nsEncoding ;

    if(strEncoding)
    {
        cfEncoding = CFStringConvertIANACharSetNameToEncoding
                                   ((CFStringRef) strEncoding);

        NSLog(@"cfEncoding %d", cfEncoding);

        if(cfEncoding != kCFStringEncodingInvalidId)
        {
            nsEncoding = (NSStringEncoding)
                      CFStringConvertEncodingToNSStringEncoding
                                                  (cfEncoding);
            NSLog(@"nsEncoding %d", nsEncoding);

            urlText = [[NSMutableString alloc] initWithData:origData
                                                encoding:nsEncoding];

            NSLog(@"urlText converted is: %d", urlText != nil);
        }
    }

thus    strEncoding was @"ISO-8859-1";
so      cfEncoding  = 513   which really is kCFStringEncodingISOLatin1
and     nsEncoding  = 5     which really is NSISOLatin1StringEncoding

The conversion of the NSString worked very well. Thank you again Scott.


Best Regards
--
Lorenzo
email: email@hidden

> From: Scott Anguish <email@hidden>
> Date: Fri, 08 Jul 2005 09:01:14 -0400
> To: Lorenzo <email@hidden>
> Subject: Re: Best encoding
>
> what about this?
>
> file:///Developer/ADC Reference Library/documentation/
> CoreFoundation/Reference/CFStringRef/Reference/
> chapter_2.1_section_6.html#//apple_ref/doc/uid/20001211-
> DontLinkChapterID_1-F11109
>
>
> On Jul 8, 2005, at 5:15 AM, Lorenzo wrote:
>
>> Hi,
>> thanks Scott, now I get a string e.g. @"ISO-8859-1"
>> But I need a NSStringEncoding. I know this method to get a
>>
>>     NSStringEncoding *strEncoding =
>>                     CFStringConvertEncodingToNSStringEncoding
>>                     ( kCFStringEncodingISOLatin1 );
>>
>> But I don't know yet how to get constant
>> kCFStringEncodingISOLatin1 from the string @"ISO-8859-1"
>>
>> Do you know how?
>>
>>
>>
>> Best Regards
>> --
>> Lorenzo
>> email: email@hidden
>>
>>
>>> From: Scott Anguish <email@hidden>
>>> Date: Fri, 08 Jul 2005 04:49:56 -0400
>>> To: Lorenzo <email@hidden>
>>> Cc: email@hidden
>>> Subject: Re: Best encoding
>>>
>>>
>>> On Jul 8, 2005, at 4:31 AM, Lorenzo wrote:
>>>
>>>
>>>> Hi,
>>>> I download some rss files from the web and I read and show the text
>>>> using
>>>>
>>>>     stringWithContentsOfFile:filePath
>>>>                     encoding:NSISOLatin1StringEncoding
>>>>                        error:&error
>>>>
>>>> Some rss requires NSISOLatin1StringEncoding, someone else requires
>>>> NSUTF8StringEncoding. So my question is: how can I detect what the
>>>> right
>>>> encoding I have to use?
>>>>
>>>> In detail
>>>> ----------
>>>> If I read the file A with NSISOLatin1StringEncoding I see the right
>>>> text.
>>>> If I read the file B with NSISOLatin1StringEncoding I see the wrong
>>>> text.
>>>> So I try to read the file B with NSUTF8StringEncoding  and I see
>>>> the right
>>>> text. But if I read the file A  with NSUTF8StringEncoding  I get
>>>> a nil
>>>> string.
>>>>
>>>>
>>>
>>>    download it and use NSXMLDocument to load it .. then you can get
>>> the characterEncoding, assuming it's specified in the file
>>>
>>
>>
>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NO future for Cocoa-Java ?
  • Next by Date: Re: Calling an Automator workflow from Cocoa?
  • Previous by thread: Re: Best encoding
  • Next by thread: append to file (new to Cocoa)
  • Index(es):
    • Date
    • Thread