[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice
Subject: Re: OpenParts - Unicode
From: Simon Hausmann <tronical () gmx ! net>
Date: 1999-04-12 17:01:28
[Download RAW message or body]
On Mon, 12 Apr 1999, Warwick Allison wrote:
> On Sat, 10 Apr 1999, you wrote:
> >Hi Warwick,
> >can you comment on the Unicode conversion question please ?
> >
> >Bye
> >Torben
> >
> >
> >On Sat, 10 Apr 1999, Simon Hausmann wrote:
> >
> >> Hello,
> >>
> >> I just took a few thoughts about making OpenParts Unicode compliant.
> >>
> >> Currently GUI related strings in OpenParts (example: part captions, menu
> >> names, and similar stuff ) are defined as "char *" based strings (or in
> >> IDL as "string" ) . This seems not to be "friendly" in regard to Qt's new
> >> QString and that's why I think this should be fixed in OpenParts soon,
> >> especially in regard to the fact that more and more people seem to get
> >> interested in using KOM/OpenParts in their applications.
> >>
> >> The way how to actually do the conversion is quite clear:
> >> (1) convert "string" into "wstring" in the interface descriptions (where
> >> it makes sense)
> >> (2) in the implementations convert "const char *" and "char *" both to
> >> "CORBA::WChar *" where necessary
> >> (3) use CORBA::WString instead of CORBA::String where necessary
> >> (4) provide two smart conversion routines between "CORBA::WChar *" and
> >> QString
> >> (5) fix a lot of method calls in all applications (...and that's the real
> >> work)
> >>
> >>
> >> About 4) : I wrote two conversion routines and put them for testing
> >> purposes into konq_txtview.cc in Konqueror, they might be useful. But
> >> since I'm no QString<->Unicode expert I'm not quite sure whether the
> >> actual conversion in these routines is correct (but they work fine here:).
> >> Perhaps some Unicode expert could check this?
>
> Looks correct to me, except an off-by-1:
>
> CORBA::WChar *res = CORBA::wstring_alloc( s.length() );
> ...
> *tmp = 0;
>
> No space was allocated for the 0 terminator.
I think it _is_ allocated.
In CORBA::wstring_alloc( len ) the allocation is done by
wchar_t *s = new wchar_t[len+1];
So I think the terminator space is included.
> You probably should also cast CORBA::WChar to ushort to be clear which QChar
> constructor is in use:
>
> *(tmp++) = QChar( (ushort) *(s++) );
Ah, yes, that's true. Thanks for the hint.
> There may be a slightly more efficient way to implement C2Q, but worry about
> that later.
Ok :-)
> The whole idea is certainly important - I don't know what the alternative would
> be - to assume that all Parts are in the same locale (giving the same encoding
> for char*) seems a bit bogus.
Hm, ...
Where/How is the encoding in Qt set, how does Qt find out about the
used locale?
If the information would come from the X-Server directly then I think it
might work since the server/display is shared for all OpenParts objects
=> same encoding, or?
Since I'm not familiar with QString internals: What could this help us?
Does this mean we could still use the good old char *'s in this case?
Greetings,
Simon
> --
> Warwick
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic