Re: can orbit/corba string support unicode
- From: Michael Meeks <michael ximian com>
- To: Gilbert Fang <gilbert fang sun com>
- Cc: orbit <orbit-list gnome org>
- Subject: Re: can orbit/corba string support unicode
- Date: 03 Dec 2002 09:46:20 +0000
Hi Gilbert,
On Mon, 2002-12-02 at 08:42, Gilbert Fang wrote:
> I wonder how orbit map the corba string (CORBA_char) in c, and how it
> implement the CORBA_string_alloc(length).
Ok - CORBA_char is just a typedef for 'char *' to meet the mapping
spec; ie. it's a plain C string, and can be used interchangably as such.
> If I want to implement a method which has a parameter --inout string,
> how could I deal with it in chinese or japanese character?
Generally inout parameters are tricky; if you have one you want to do:
CORBA_free (*inOutStr);
*inOutStr = CORBA_string_dup ("Foo");
See ORBit2/test/everything for some torturous tests of various sorts.
> Generally, for eg, one chinese char has 2 byte . So if I have a string
> with 2 chinese char, should I use
> CORBA_string_alloc(2) or CORBA_string_alloc(4)?
Neither - they both allocate a string of length 2 or 4 characters.
I can't _Emphasize_ this enough:
Abandon all hope of excessive multi-byte character
string complexity, Gnome(2) uses a single scheme: UTF8, all
strings are encoded as UTF8, they thus all have 'char *'
pointers, which point at arrays of 8bit entities, encoding UCS4.
For more information read '$ man utf-8'.
Please, please - forget about wchar_t, unichar_t, UCS-2, UTF-16, and
all other abominations. Simply focus on UTF8 and how pleasant life is
with it.
> I guess that CORBA_char is char , is that right?
> If I do
> CORBA_char * astr=CORBA_string_alloc(2);
> can I
> strcpy(astr, "HI");
> then
> Echo_echoString(astr);
No need; you can do :
Echo_echoString (obj, "hi", ev);
since it's a native C type - the mapping is designed that way. Also,
for every 'alloc' there must be a 'free' ;-) in this case CORBA_free
'smart' frees every ORB allocated type.
> Every one is saying that I can find answer in c mapping spec, but
> actually c mapping spec has not described the detail fo one corba
> implementation. It does not say what is the really type of corba_long,
> it depends on how orbit implement it. And it does not say how
> translate/co-op the raw c type with the corba type.
Sigh - I think the mapping does specify this; but reading the mapping
is acutely painful. I'd just read the ORBit2 regression tests in
test/everything if you ever have a query.
Oh - and finally - learn to love utf-8 ;-)
HTH,
Michael.
--
mmeeks@gnu.org <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]