• 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
Best way to parse XML data of non-ASCII encoding...?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best way to parse XML data of non-ASCII encoding...?


  • Subject: Best way to parse XML data of non-ASCII encoding...?
  • From: Simon Liu <email@hidden>
  • Date: Tue, 5 Apr 2005 18:12:16 +0100

Hi,

I am doing some XML parsing for 10.2+, thus I am using Core
Foundation's XML functions, such as CFXMLTreeCreateFromData().

Things are working fine except for XML files with non-ASCII
characters.  The functions seem to ignore the encoding attribute of
the xml tag, such as in:

<?xml version="1.0" encoding="shift_jis" standalone="yes"?>

Given an XML file in the above encoding, with Japanese characters as
values between tags, the routines crash.

However, if I first convert the file to UTF8, things work fine...

NSString *s = [NSString stringWithContentsOfURL:sourceURL];
NSData *xmlData = [s dataUsingEncoding:NSUTF8StringEncoding];
// use as CFDataRef in CFXMLTreeCreateFromData()

Is this the expected behaviour?  Is there a more elegant way to parse
non-ASCII XML files?

Regards,
Simon
 _______________________________________________
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: NSKeyed archiver archive format in human readable format ?
  • Next by Date: Re: PreferencePane plugin: awakeFromNib gets called twice
  • Previous by thread: NSKeyed archiver archive format in human readable format ?
  • Next by thread: Re: Best way to parse XML data of non-ASCII encoding...?
  • Index(es):
    • Date
    • Thread