Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use Unicode with Carbon



Felipe Monteiro de Carvalho wrote:

I tryed to use this to change the title of a window when a button is
pressed, but it doesn't work.

I am using this string:

const
  MyUTF8String = 'Texto ł ñ ø ß á';

Encoded with UTF-8. I opened the file with TextWrangler to ensure it's
really utf-8

And tryed to set the window title with this code:

function ButtonMessagePressed: OSStatus;
var
  CFString: CFStringRef;
begin
  CFString := CFStringCreateWithCString(nil,
Pointer(PChar(MyUTF8String)), kCFStringEncodingUTF8);

  SetWindowTitleWithCFString(MainWindow, CFString);

  CFRelease(CFString);

  result := 0;
end;

But it doesn't work. I only see 'Texto' and not my entire string. i.e.
the special characters disappeared.

I looked at the apple docs for SetWindowTitleWithCFString, but they
don't say anything special.
http://developer.apple.com/documentation/Carbon/Reference/Window_Manager/Reference/reference.html#//apple_ref/c/func/SetWindowTitleWithCFString

Does anyone have an idea of what is wrong?

For me (using FPC/LWP), your program crashes in CFCreateWithCString. I changed
it to the obvious alternative CFCreateWithPascalString (to avoid the cast and convert),
but it seems the problem is the kCFStringEncodingUTF8.


I see that you solved the problem, but I would be interested in knowing how. I am
not using the same editor as you, and I see the another bug. Do you mean it is a
matter of saving the source-code file in UTF8 format? Of course, I would rather
suggest saving only the string in that format. Maybe this is a problem which is not
very suitable for a single-file demo?


Concerning language, I want the right to think different - even in other ways than
Apple proclaims.



/Ingemar

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.