[Gambas-user] Re: Text Search - string/textarea Issue - 1.0.14

Benoit Minisini gambas at ...1...
Mon Mar 20 23:29:59 CET 2006


On Monday 20 March 2006 17:46, A Person wrote:
> Good Day All . . .
>
> Thanks for the replies.
>
> Ron - Your code does not work here. Normally it should work but I am
> dealing with bytes and UTF-8 -- apples and oranges. I tried this earlier
> and it would not work. It does work when I substitute a normal string. I
> have done for years. See the bottom of this message.
>
> Benoit - Apples and oranges explains why the INSTR function passes the
> end of text and does not raise an alarm. I had a feeling that this was
> the case. Earlier I added an end of file marker such as:
>
> sTemp = textareHelp.Text & CHR$(13) & CHR$(10)
>
> but it did not work.
>
> This brings me to the point of the exercise how do I:
>
> a. Search a string made up of textarea text where a search will fail at
> the last character(?) ?
>
> or
>
> b. Convert the textarea text into something where a search will fail at
> the last character?
>
> or
>
> c. What function is used to search a textarea and fail at the last
> character(?) ?
>
> or
>
> d. Or load the the original help.txt file into a string when the user
> opens the help screen, search the string with INSTR and convert the
> return into textarea.selection. The INSTR function will stop at the end
> of the string with a little coaching. This seems a logical workaround.
>
> Any suggestions?
>
> Thanks.
>
> Paul
>

First, you must understand what is UTF-8, and how it is coded.

The more important feature with UTF-8 is that it is compatible with ASCII, so 
some ASCII Gambas string functions work with UTF-8 string.

For example, Instr() and RInstr() will work, except that they will return a 
byte position, not a character one.

To convert between byte position and UTF-8 character position, use the String 
static class. In this class, you will find other UTF-8 specific functions.

Regards,

-- 
Benoit Minisini





More information about the User mailing list