Forum > General

Copy function can not handle utf8 chars like ä,ü,ß...

(1/1)

Soner:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var s,s2:string;begin  s:='Özßönkrsöäüänöüä';    s2:=Copy(s,1,6);     // s2 is 'Özß?'  , copy calculated ö at 6.char.                                // it should be 'Özßönk'                                                  s2:=Copy(s,1,7);     // s2 is 'Özßö'                                                                                               // it should be 'Özßönkr' 
Is in the RTL a function that can copy strings right way?

Handoko:
Maybe this can help:
https://forum.lazarus.freepascal.org/index.php?topic=53938.0

Soner:
Thanks Handoko.
Utf8copy can handle it right.
I thougt it is removed but it is still in lazUTF8 unit.

Navigation

[0] Message Index

Go to full version