PDA

View Full Version : Other conversion posible



davinciomare
26th September 2016, 12:31
Hi i have one question about this example:

QByteArray array;
array = ui->textocuenta->text().toLatin1();
I could use other conversion for the text different toLatin1????

anda_skoa
26th September 2016, 12:41
Yes, QString has built in conversions for "latin1" (western european charset), "utf8" and "local 8 bit" (depends on local settings).

An even wider range of encodings can be done through QTextCodec.

Cheers,
_

davinciomare
26th September 2016, 13:13
pls can you take me a exampel of this:
datoss = "|@|" + ui->textocuenta->text().toLatin1() + "|@|";

with qtextcode. thanks in advance. I need because i need to avoid this conversion.

anda_skoa
26th September 2016, 14:24
The QTextCodec equivalent of


const QByteArray data = ui->textocuenta->text().toLatin1();

is


QTextCodec *codec = QTextCodec::codecForName("latin1");
const QByteArray data = codec->fromUnicode(ui->textocuenta->text());


Cheers,
_