[Gambas-user] Fwd: Problem to be examined by those who must use UTF8 with Gambas

Benoît Minisini gambas at ...1...
Tue Jul 4 15:12:01 CEST 2017


Le 02/07/2017 à 01:12, Fernando Cabral a écrit :
> ---------- Forwarded message ----------
> From: Fernando Cabral <fernandojosecabral at ...626...>
> Date: 2017-07-01 17:34 GMT-03:00
> Subject: Re: [Gambas-user] Problem to be examined by those who must use
> UTF8 with Gambas
> To: Jussi Lahtinen <jussi.lahtinen at ...626...>
> 
> 
> 2017-07-01 16:15 GMT-03:00 Jussi Lahtinen <jussi.lahtinen at ...626...>:
> 
>> I don't quite get your description of the problem. It seems self
>> contradictory. I mean this part:
>>
>> Perhaps It should sound contradictory. That's because if I write directly
> to a TextArea.text from
> inside the program, it will show "À" correctly. Nevertheless, if I read the
> same string from a file read into a variable and then try to display it...
> it does not work.
> 
>> Are you using ascii functions for UTF-8 at some point?
> 
> I only use ascii functions where there are no UTF-8 functions. For
> instance, split().
> 
>> I think we need to see your code to understand the issue.
> 
> I have attached a text file (ODT) as well as the code itself. Note that, in
> order to run the code you will have to have unoconv installed.
> 
> If you comment the two lines bellow, the code will not work.
> 
> 
> 
> * RawText = RegExp.Replace(RawText, "À", "à") RawText =
> RegExp.Replace(RawText, "Ó", "ó")*
> 
> This happens because for some mysterious reason, the QT library seems to
> get confused
> with *À* and *Ó*. But not always!
> 
> Jussi
> 

Not mysterious: you are using UTF-8 separators with Split(), whereas 
Split() only deals with ASCII strings. Consequently, the resulting 
MatchedWords array gets incorrect UTF-8 strings.

If you have took the time to just trace your program between line #54 
and line #60 and watch the MatchedWords array, you would have seen the 
problem.

Regards,

-- 
Benoît Minisini




More information about the User mailing list