Recent

Author Topic: Lazarus function pos can't read character "á" .......  (Read 7650 times)

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Lazarus function pos can't read character "á" .......
« on: March 07, 2009, 04:19:29 am »
Hi friends.I'm doing a soccerapp and I use synapse to pick the soccer fixtures to a textfile and then I use pos to search for the fixture in the textfile.
Everything is working fine but,when I try to let pos read Spanish fixtures like Málaga with the character "á" in the word, pos can't find it!

I use Lazarus(0.9.26) in Linux Ubuntu 8.10  with string;

Someone have an idéa?

here's my soccerapp:
http://hem.bredband.net/robbanux

 ;)
Rob

vvzh

  • Jr. Member
  • **
  • Posts: 58
Re: Lazarus function pos can't read character "á" .......
« Reply #1 on: March 07, 2009, 08:23:31 am »
It looks like an encoding problem, so the solution depends on the encoding of your text file.

If you take text strings from Lazarus controls such as TEdit and then save them to a file, these strings will be in UTF-8 encoding. In this case you can use UTF8Pos instead of plain Pos. In order to use it you need to add LCLProcs to the unit "uses" clause.

Robert W.B.

  • Sr. Member
  • ****
  • Posts: 331
  • Love my Wife, My Kids and Lazarus/Freepascal.
Re: Yes,it's a encoding problem ,I know that now but..
« Reply #2 on: March 08, 2009, 11:51:20 pm »
what You suggested dosen't work for me in Linux!
I use cwstring unit and WideString in linux but  characters like "á"  "é" will only shows like this "?"
ex: Málaga=M?laga   Atléticho=Atl?ticho

Anyone knows the sollution?

Linux Ubuntu
Lazarus 0.9.26 FPC 2.2.3
 %)
Rob

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Yes,it's a encoding problem ,I know that now but..
« Reply #3 on: March 09, 2009, 08:33:16 am »
what You suggested dosen't work for me in Linux!
I use cwstring unit and WideString in linux but  characters like "á"  "é" will only shows like this "?"
ex: Málaga=M?laga   Atléticho=Atl?ticho

Anyone knows the sollution?

Linux Ubuntu
Lazarus 0.9.26 FPC 2.2.3
 %)

You can try to convert in UTF8 format the string before to use "Pos":

WrkStr:=UTF8Encode(YourString);
WrkPos:=Pos('à', WrkStr);

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1933
Re: Yes,it's a encoding problem ,I know that now but..
« Reply #4 on: March 09, 2009, 10:17:29 am »
I use cwstring unit and WideString in linux

You don't need WideString, just leave it UTF-8 (AnsiString).

 

TinyPortal © 2005-2018