[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: QString data
From:       Tim Jansen <ml () tjansen ! de>
Date:       2003-08-20 11:25:48
[Download RAW message or body]

On Wednesday 20 August 2003 12:37, Johnny Andersson wrote:
> Let's say I have a memory buffer with utf16 data. I want to set a QString
> to use this data, that is, I want to avoid a copy operation.

This is not possible, since utf16 strings have (like utf8) a variable 
character length, and QString's internals do not support this.

> I guess what I want is something like QConstString(const char *, int).
> Info appreciated.

You can cast your string to const QChar* and use it as argument of 
QConstString ( const QChar * unicode, uint length ), provided that:
- you are sure that all characters in your utf16 string have only 16 bits (you 
may need to check that)
- you did not compile Qt with QT_QSTRING_UCS_4. In other words, QChar has 2 
bytes and not 4. You can check that at compile time, a sizeof(QChar) should 
be enough

bye..

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic