Panagiotis Sidiropoulos wrote:
It returns 41. Seems to be correct.
I'm using fpc 2.0.2.


Greek k suggested when sample project I up, is in position 21 in the
string, not 41.
When using sample project, I get following relults while search for each
character in "String to search in" edit box:
- 1st: position: 1 - correct
- 2nd: position: 3 - wrong
- 3rd: position: 5 - wrong
- 4th: position: 7 - wrong
and so on

I also use FPC 2.0.2 downloaded a few days ago at
ftp://ftp.de.freepascal.org/pub/fpc/dist/i386-linux-2.0.2/fpc-2.0.2.i386
-linux.tar.
An ftp server choosed in Germany, I suppose all server support same
build.

pos return the position is bytes not in chars

I think you can use the UTF8Length to get the character position.
http://lazarus-ccr.sourceforge.net/docs/lcl/lclproc/utf8length.html

ps := pos(c,s);
if (ps>0) then
        CharacterPos := UTF8Length(Copy(s,1,ps-1)+
else
        CharacterPos := 0;

Vincent.

P

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to