exposed StringFromUTF16 utility function so it can be used from within form1.ui.h

This commit is contained in:
jmiltner
2005-03-24 16:51:35 +00:00
parent 7513a5b5ce
commit ce47263176
3 changed files with 20 additions and 24 deletions

View File

@@ -819,14 +819,7 @@ void mainForm::executeQuery()
mustCreateColumns = false;
}
for (int e=0; e<ncol; e++){
const ushort* utf16data = static_cast<const ushort*>(sqlite3_column_text16(vm, e));
QString rv;
uint utf16len=0;
if ( utf16data ) {
for ( const ushort* p = utf16data; *p; ++p )
++utf16len;
rv.setUnicodeCodes(utf16data, utf16len);
}
QString rv(StringFromUTF16(sqlite3_column_text16(vm, e)));
//show it here
QString firstline = rv.section( '\n', 0,0 );
if (firstline.length()>MAX_DISPLAY_LENGTH)

View File

@@ -7,24 +7,23 @@
#include <qfiledialog.h>
#include <qmessagebox.h>
namespace {
uint utf16len(const ushort* utf16)
{
uint len=0;
if ( utf16 )
while ( *utf16++ ) ++len;
return len;
}
QString StringFromUTF16(const void* utf16)
{
QString result;
result.setUnicodeCodes(static_cast<const ushort*>(utf16), utf16len(static_cast<const ushort*>(utf16)));
return result;
}
//utility functions
uint utf16len(const ushort* utf16)
{
uint len=0;
if ( utf16 )
while ( *utf16++ ) ++len;
return len;
}
QString StringFromUTF16(const void* utf16)
{
QString result;
result.setUnicodeCodes(static_cast<const ushort*>(utf16), utf16len(static_cast<const ushort*>(utf16)));
return result;
}
void DBBrowserTable::addField(int order, const QString& wfield,const QString& wtype)
{
fldmap[order] = DBBrowserField(wfield,wtype);

View File

@@ -34,6 +34,10 @@ typedef QMap<int, int> rowIdMap;
typedef QValueList<QStringList> rowList;
typedef QMap<int, QString> resultMap;
//utility functions
uint utf16len(const ushort* utf16);
QString StringFromUTF16(const void* utf16);
class DBBrowserField
{
public: