From: Peter J. Holzer on
On 2010-02-18 08:08, J�rgen Exner <jurgenex(a)hotmail.com> wrote:
> mud_saisem <mud_saisem(a)hotmail.com> wrote:
>>so that I can use the seek function
>
> Now, that is the critical clue. seek() is based on bytes, so you need a
> position in bytes in order to use seek().
> Position in characters would do you no good and therefore my suggestion
> with index() wouldn't do you any good, either, because it returns the
> position in characters.

Only if you use index() on character strings - if you use index on byte
strings it returns a byte position. So just read the file in binary,
convert your search string to the same encoding and invoke index().

Caveat: Some encodings are ambiguous: The same character sequence may be
represented by different byte sequences. For those encodings, index
won't work.

hp