converting from Big 5 and GuoBiao encodings

  • Hi,

    I am trying to build a generic parser for various files I expect to
    encounter. To get the file in the form of a string, I was going to use:

    NSString *fileAsString = [[NSString alloc] initWithContentsOfFile:
    sourcePath
        encoding: NSUTF8StringEncoding
        error: &error];

    That works assuming the encoidng is UTF8. But what if it is Big 5 or
    GuoBiao? I couldn't find an equivalent encoding in
    the documentation.

    Thanks.

    Daniel
  • You can get NSStringEncoding IDs for these encodings by converting
    CFStringEncoding.

    To get the Mac variant of Big5 (Mac Traditional Chinese), you can do
    CFStringConvertEncodingToNSStringEncoding
    (kCFStringEncodingMacChineseTrad).

    Refer to http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringR
    ef/Reference/reference.html#/

    /apple_ref/c/func/CFStringConvertEncodingToNSStringEncoding

    Aki

    On 2008/01/10, at 19:22, Daniel Child wrote:

    > Hi,
    >
    > I am trying to build a generic parser for various files I expect to
    > encounter. To get the file in the form of a string, I was going to
    > use:
    >
    > NSString *fileAsString = [[NSString alloc] initWithContentsOfFile:
    > sourcePath
    > encoding: NSUTF8StringEncoding
    > error: &error];
    >
    > That works assuming the encoidng is UTF8. But what if it is Big 5 or
    > GuoBiao? I couldn't find an equivalent encoding in
    > the documentation.
    >
    > Thanks.
    >
    > Daniel
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today