Recent

Author Topic: Copy function can not handle utf8 chars like ä,ü,ß...  (Read 1822 times)

Soner

  • Sr. Member
  • ****
  • Posts: 305
Copy function can not handle utf8 chars like ä,ü,ß...
« 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?

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus

Soner

  • Sr. Member
  • ****
  • Posts: 305
Re: Copy function can not handle utf8 chars like ä,ü,ß...
« Reply #2 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