Qt-interest Archive, April 2007
QStrings in Spanish
Message 1 in thread
I am having a rare problem with a Spanish dictionary I am comparing
QStrings against..
basically when I use a short list < 100 words for example then
everything works ok..
I can lookup words with accents and enyes etc.
but when I use the whole diccionary with 27.000+ words then only works when
the word has no special character(Accents) ...
ok now I ask myself why does it work on a small scale but not with more
words?
I am trying to find the logic of this but I keep coming back to 0
if it was a unicode problem then short list will also not work
if it was a problem of list size only then nothing will work at all with
long list.. but it does only special chars search wont..
and so on..
I have 0 ideas..
Any help will be very appreciated.
the code is a base QFile and a QTextStream that reads the file line by
line and
adds the value to a QString that I then compare with my QString...
basically a regular search,..
--
[ signature omitted ]
Message 2 in thread
Hi,
> I am having a rare problem with a Spanish dictionary I am comparing
> QStrings against..
> basically when I use a short list < 100 words for example then
> everything works ok..
> I can lookup words with accents and enyes etc.
> but when I use the whole diccionary with 27.000+ words then only works when
> the word has no special character(Accents) ...
> ok now I ask myself why does it work on a small scale but not with more
> words?
Something else must be happening, it can't be a matter of scale, especially
since 27.000 is not that a large scale. Maybe some words are not read
correctly from the file. Maybe the Qt works as documented, although that's not
what you expect. In any case I don't see why using 27.000 words would be a
problem.
It would help if you could explain us what doesn't work exactly.
--
[ signature omitted ]
Message 3 in thread
>
>
> It would help if you could explain us what doesn't work exactly.
>
well basically words with spanish special characters like ñ are not been
found when opening the file with QFile and
using QTextStream by line and comparing this line QString against
another QString I have typed before the search..
goes all the way to the end of the file...
but when I do this with a shorter list then it works..
QFile fichero("es_ES.dic");
if (!fichero.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QTextStream leer(&fichero);
leer.setCodec("UTF-8");
while (!leer.atEnd()) {
Linea = leer.readLine();
if ( Palabra == Linea ) {
Acento = "NO se acentua";
break;
} else {
Acento = "SI se acentua";
}
...
this is not exactly the code is very similar I took out all the things
inside the { } if it does match Linea,
I try it this way and I get the same problem. I only change lists one is
short and the other one the original big.
note that the big works fine if the QString to search for has no special
characters..
I try the seCodec see if it any difference but it does the same thing
with or without for what I understand QString already works on unicode.
..........
> --
> Dimitri
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
begin:vcard
begin:vcard
fn:ReK2 Wilds
n:Wilds;ReK2
email;internet:rek2@xxxxxxxxxxxxxxxxxx
note;quoted-printable:"To liberate the code, if it is possible, would not be theft, any more=
than freeing a slave is theft (which is what the slave owner would surel=
y call it)."=0D=0A=
=0D=0A=
Join the FSF as an Associate Member at:=0D=0A=
<URL:http://www.fsf.org/register_form?referrer=3D697>=0D=0A=
url:http://www.binaryfreedom.info
version:2.1
end:vcard
Message 4 in thread
El Miércoles 25 Abril 2007, rek2 GNU/Linux LO LO LO escribió:
> > It would help if you could explain us what doesn't work exactly.
>
> well basically words with spanish special characters like ñ are not been
> found when opening the file with QFile and
> using QTextStream by line and comparing this line QString against
> another QString I have typed before the search..
> goes all the way to the end of the file...
> but when I do this with a shorter list then it works..
Try adding:
QLocale::setDefault(QLocale::UTF8);
before:
> QFile fichero("es_ES.dic");
Regards, Lisandro.
--
[ signature omitted ]
Message 5 in thread
Hi,
> well basically words with spanish special characters like ñ are not been
> found when opening the file with QFile and
> using QTextStream by line and comparing this line QString against
> another QString I have typed before the search..
> goes all the way to the end of the file...
> but when I do this with a shorter list then it works..
There must be a difference between the cases of the short and the long file,
such as:
* long and short files have different encodings
* file is not found in the case of the large file (incorrect path)
* the word you're looking is missing from the large file
* ...
Note that the OpenOffice dictionary es_ES.dic is *not* UTF-8 encoded on my
Linux system. The encoding appears to be ISO 8859-1 / Latin1. Try changing from:
leer.setCodec("UTF-8");
to:
leer.setCodec("ISO 8859-1");
--
[ signature omitted ]
Message 6 in thread
>
> There must be a difference between the cases of the short and the long
> file, such as:
> * long and short files have different encodings
> * file is not found in the case of the large file (incorrect path)
> * the word you're looking is missing from the large file
> * ...
>
> Note that the OpenOffice dictionary es_ES.dic is *not* UTF-8 encoded
> on my Linux system. The encoding appears to be ISO 8859-1 / Latin1.
> Try changing from:
> leer.setCodec("UTF-8");
> to:
> leer.setCodec("ISO 8859-1");
yes basically this is the openoffice dic for spanish is GPL so I am
using it for my project that is also GPL.
let me try this.
also it is possible that the short file is valid because is a file I
created.. the other one I download it..
Thanks so much when I get home I try this.
Chris
begin:vcard
begin:vcard
fn:ReK2 Wilds
n:Wilds;ReK2
email;internet:rek2@xxxxxxxxxxxxxxxxxx
note;quoted-printable:"To liberate the code, if it is possible, would not be theft, any more=
than freeing a slave is theft (which is what the slave owner would surel=
y call it)."=0D=0A=
=0D=0A=
Join the FSF as an Associate Member at:=0D=0A=
<URL:http://www.fsf.org/register_form?referrer=3D697>=0D=0A=
url:http://www.binaryfreedom.info
version:2.1
end:vcard