Subject: Re: bug#7282: 23.2; [PATCH] Improve text composition by Input Methods on MacOSX.

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Thu, 28 Oct 2010 15:35:38 +0900

>>>>> On Thu, 28 Oct 2010 15:15:54 +0900, Keitaro Miyazaki <[email-masked]> said:

> Do you mean that there are some cases that the number of characters
> in a string, in other words, the length of a string, is different
> from the one counted by NSString to the one counted by Emacs?

> If so, could you show me any example of these cases?

I mentioned "non-BMP characters" in the previous reply.

(mapcar 'length (list (string #xffff) (string #x10000)))

=> (1 1)

#import <Cocoa/Cocoa.h>
#include <stdio.h>

main()
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  const char str1[] = {0xef, 0xbf, 0xbf, '\0'}; // U+ffff in UTF-8
  const char str2[] = {0xf0, 0x90, 0x80, 0x80, '\0'}; // U+10000 in UTF-8
  NSString *string1 = [NSString stringWithUTF8String:str1];
  NSString *string2 = [NSString stringWithUTF8String:str2];

  printf ("%ld %ld\n", [string1 length], [string2 length]);
  [pool release];
}

=> 1 2

				     YAMAMOTO Mitsuharu
				[email-masked]