Lazarus

Free Pascal => General => Topic started by: Soner on June 18, 2021, 06:54:34 pm

Title: Copy function can not handle utf8 chars like ä,ü,ß...
Post by: Soner on June 18, 2021, 06:54:34 pm
Copy function can not handle utf8 chars like ä,ü,ß, it counts 2 characters for those.
If an umlaut is in the last from copy-function calculated position then it intersects the character and results at the end '?'.

Look at the examples:
Code: Pascal  [Select][+][-]
  1. var s,s2:string;
  2. begin
  3.   s:='Özßönkrsöäüänöüä';  
  4.   s2:=Copy(s,1,6);     // s2 is 'Özß?'  , copy calculated ö at 6.char.
  5.                                 // it should be 'Özßönk'
  6.                                                
  7.   s2:=Copy(s,1,7);     // s2 is 'Özßö'                                              
  8.                                                 // it should be 'Özßönkr'
  9.  

Is in the RTL a function that can copy strings right way?
Title: Re: Copy function can not handle utf8 chars like ä,ü,ß...
Post by: Handoko on June 18, 2021, 06:58:45 pm
Maybe this can help:
https://forum.lazarus.freepascal.org/index.php?topic=53938.0
Title: Re: Copy function can not handle utf8 chars like ä,ü,ß...
Post by: Soner on June 18, 2021, 07:07:01 pm
Thanks Handoko.
Utf8copy can handle it right.
I thougt it is removed but it is still in lazUTF8 unit.
TinyPortal © 2005-2018