ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Hihin Ruslan <ruslandh@gmail.com>
To: devel@lists.altlinux.org
Subject: Re: [devel] Странности с QT
Date: Thu, 3 Nov 2011 08:32:53 +0400
Message-ID: <201111030833.00832@ruslandh> (raw)
In-Reply-To: <4EB1C7D2.5020003@altlinux.org>

[-- Attachment #1: Type: text/plain, Size: 2534 bytes --]

Здравствуйте Paul Wolneykien
  В сообщении от 3 ноября 2011 Paul Wolneykien написал(a):
>  Я имел в виду, что пробел вставляется в дополнение к байту из
> исходной строки in. Это нормально?
Я так понимаю, что ошибка где-то раньше - в том, что туда попали 
пробелы.
Не могу гарантировать, но IMHO - это нормально.

Как я понимаю, пробелы возникли из-за чего-то, связанного с 
уникодом. Насколько я помню, QT хранит данные в юникоде (и даже 
не utf8. а в чём-что ещё). И сколько занимает один символ - не 
определено (зависит от языка и т.п.). 

Теперь полез по справочникам:

Функция at вытаскивает символ типа QChar по индексу. 
Вот - описание QCcar:
"The QChar class provides a 16-bit Unicode character.
In Qt, Unicode characters are 16-bit entities without any markup 
or structure. This class represents such an entity. It is 
lightweight, so it can be used everywhere. Most compilers treat 
it like a unsigned short."

Т.е. один QChar занимает 2 байта. 


QByteArray bb(4, ' '); - отводит 4 байта (не символа).  IMHo 
отсюда и проблема. 16-битный символ пытаются запихнуть в один 
байт. 

Т.е. должно быть что-то типа:
   QByteArray bb(8, ' ');
       bb = bb.insert(6, in.at(0));
       bb = bb.insert(4, in.at(1));
       bb = bb.insert(2, in.at(2));
       bb = bb.insert(0, in.at(3));

Начсколько это верно, зависит от операции = (как приводятся типы 
и т.п.)

Или
QChar bb[4]
bb = in.at(0);
....
bb = in.at(3));

Я конечно могу ошибаться, но ошибка возникает из-за представления 
программиста, что символ занимает один байт.


-- 
  А ещё говорят так  (fortune):
 
The trouble with you Is the trouble with me. Got two good eyes 
But we still don't see. -- Robert Hunter, "Workingman's Dead" 
________________________________________________________________________
С уважением Хихин Руслан

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2011-11-03  4:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 19:10 Paul Wolneykien
2011-11-02 21:33 ` Hihin Ruslan
2011-11-02 22:44   ` Paul Wolneykien
2011-11-03  4:32     ` Hihin Ruslan [this message]
2011-11-03  5:04       ` Sergei Epiphanov
2011-11-03  6:59         ` Damir Shayhutdinov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201111030833.00832@ruslandh \
    --to=ruslandh@gmail.com \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git