Calculating Offsets into the Delphi editor buffer

Calculating Offsets into the Delphi editor buffer

The animated GIF in my previous post shows how the new AutoTodo expert in GExperts works. Unfortunately it turned out later that, again, I had overlooked a Unicode issue. If the editor buffer contains any Unicode characters, the offsets for inserting the todos where off by one for each of these characters, so the todos were inserted in the middle of the source code rather than at the empty blocks.
http://blog.dummzeuch.de/2016/03/12/calculating-offsets-into-the-delphi-editor-buffer/

Comments

  1. Probably off by at least one. Try with characters that encode to 3 or 4 bytes...

    ReplyDelete
  2. You're right, I tend to forget that there are UTF-8 characters with more than two bytes.

    ReplyDelete
  3. It's even worse than just pairs. Some Unicode characters are combinatory, so they will position themselves in the same position as the previous character.
    https://en.wikipedia.org/wiki/Combining_character

    ReplyDelete

Post a Comment