• 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: NSString creating problem when contains chinese font
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString creating problem when contains chinese font


  • Subject: Re: NSString creating problem when contains chinese font
  • From: Calvin Hou <email@hidden>
  • Date: Wed, 01 Oct 2003 14:22:13 -0400

Kusterer, thank you for your reply.

The Chinese code uses 2 byte for one Chinese character. Each byte in greater
than 0x80.

If I don't modify the Chinese character in the contents[], the NSString is
created correctly, and all of the ASCII and Chinese in the string is
displayed correctly. So I think the USF8 is suitable for what read from the
file.

The problem appears when I modify the Chinese word. Even copying the second
word onto the first one does not work. Like,
Contents[0] = contents[2];
Contents[1] = contents[3];

I checked the value in the contents[], ASCII uses one byte, such as 0x75 for
'u', 0x64 for 'd'.


Calvin



> From: "M. Uli Kusterer" <email@hidden>
> Date: Wed, 1 Oct 2003 19:49:18 +0200
> To: Calvin Hou <email@hidden>, <email@hidden>
> Subject: Re: NSString creating problem when contains chinese font
>
> At 11:23 Uhr -0400 01.10.2003, Calvin Hou wrote:
>> //Modify one chinese character, if don't changed, everything is fine.
>> contents[55] = 0xB8; contents[56] = 0x71;
>>
>> // Create NSString temp which will be displayed in NSTextView
>> NSString * temp = [[NSString alloc] initWithUTF8String: contents];
>
> Jus a guess:
>
> Either the comment is wrong, or you're using the wrong encoding. You
> say "modify ONE chinese character". But you're changing two bytes to
> binary values. Then you're saying initWithUTF8String. UTF8 uses
> eight-bit (one byte) characters and escape sequences to specify
> characters.
>
> Make sure the loaded string is what you expect (by logging
> "contents") and find out what its encoding is. Chances are, that it's
> Apple's old encoding and not Unicode, or if it is Unicode, that you
> are expecting the old encoding.
>
> I'm not a Unicode guru, but IIRC Unicode escape sequences mainly
> stick to low-range ASCII values and use sequences that look something
> like "//1234" to indicate characters that can't be represented in 8
> bits.
> --
> Cheers,
> M. Uli Kusterer
> ------------------------------------------------------------
> "The Witnesses of TeachText are everywhere..."
> http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSString creating problem when contains chinese font
      • From: "M. Uli Kusterer" <email@hidden>
References: 
 >Re: NSString creating problem when contains chinese font (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: NSTableView text color question
  • Next by Date: Re: NSString creating problem when contains chinese font
  • Previous by thread: Re: NSString creating problem when contains chinese font
  • Next by thread: Re: NSString creating problem when contains chinese font
  • Index(es):
    • Date
    • Thread