0

XML ファイルに Big-5 の漢字が含まれています。以下のコードに基づいて UTF-8 に変換する方法を教えてください。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSString *xmlFilepath = [[[NSBundle mainBundle] resourcePath]  stringByAppendingPathComponent:@"Hostels.xml"];


    NSData *xml = [[NSData alloc] initWithContentsOfFile:xmlFilepath];



    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xml];

    Parser *theParser = [[Parser alloc] initParser];

    [xmlParser setDelegate:theParser];

.......
4

1 に答える 1

0

Try to use this piece of code to extract Big-5 encoded Chinese characters

//-2147481085,  // Traditional Chinese (Big 5)
//-2147481082,  // Traditional Chinese (Big 5 HKSCS)
//-2147482589,  // Traditional Chinese (Windows, DOS)
//-2147483646, //Traditional Chinese (Mac OS)
#define NSBIG5Encoding -2147482589
NSString* content = [NSString stringWithContentsOfFile:fileParh_
                                              encoding:NSBIG5Encoding
                                                 error:nil];
NSData *XMLData = [content dataUsingEncoding:NSUTF8StringEncoding];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:XMLData];
于 2012-09-24T04:33:50.267 に答える