Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-01

how to pass a unicode string pointer in Mac OSX

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Guru Kathiresan

Hello,

I'm wondering how to pass a unicode string to a C function in Mac.

The C export function has the following definition

void  function1(wchar_t *str);

In windows wchar_t size is 2 so I thought I can pass a WideString type casted with PWideChar.

In Mac ,size of wchar_t is 4 in the C library and the size of WideChar in FPC is 2.

In that case how do we convert the 2 byte WideChar to 4 byte wchar_t string?

Thanks,

Guru Kathiresan

Reply by email

Jonas Maebe
to Guru Kathiresan
Guru Kathiresan wrote 9 lines
In windows wchar_t size is 2 so I thought I can pass a WideString type casted with PWideChar. In Mac ,size of wchar_t is 4 in the C library and the size of WideChar in FPC is 2. In that case how do we convert the 2 byte WideChar to 4 byte wchar_t string?
You can use this function from the system unit:
function WideStringToUCS4String(const s : WideString) : UCS4String;
And for the other way around:
function UCS4StringToWideString(const s : UCS4String) : WideString;

Jonas

Reply by email