Corrupted strings lazarus / 21-General ---------------------------------------------------------------------- LemonParty · 2025-12-05 14:02 Hello. Let's say we have this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  S: String = '12345';begin  S[3]:= #0;end. Is string after this manipulation become corrupted? How should be processed zeroes in the middle of the string? ---------------------------------------------------------------------- marcov · 2025-12-05 14:14 A Pascal string can contain any character as the length is stored separately, so that would simply be a pascal string with a null character in third position. However since many GUI and console libraries are C based, they often can't deal with nulls, as they see it as the end of a string. So in summary, that construct is fine, but displaying it can be troublesome. ---------------------------------------------------------------------- jamie · 2025-12-05 14:28 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SelLength(S, Pos(#0,S));  Something like that. ---------------------------------------------------------------------- LemonParty · 2025-12-05 16:13 Thank you. ---------------------------------------------------------------------- Aruna · 2025-12-06 19:25 Quote from: LemonParty on December 05, 2025, 03:02:10 pmHello. Let's say we have this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  S: String = '12345';begin  S[3]:= #0;end. Is string after this manipulation become corrupted? How should be processed zeroes in the middle of the string? You are replacing '3' (the third character) with #0. So internally, the string bytes become: S[1] = '1' S[2] = '2' S[3] = #0 S[4] = '4' S[5] = '5' The length of S is still 5. Nothing is automatically truncated. The string is not corrupted, but you need to be careful when interfacing with routines that expect null-terminated strings. I have attached a zip for you to play around with. Have fun!