Forum > LazUtils
Error in LazStringUtils.SpecialCharsToHex?
(1/1)
dsiders:
I stumbled across this recently...
The name of the routine implies it converts special characters to hexadecimal character constants. It does not.
It uses decimal (%d in its Format argument instead of %x). And converts to #ddd notation instead of #$xx.
Just looking for confirmation before filing a bug report.
lucamar:
I can confirm. Something like:
--- 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";}};} ---procedure TForm1.Button1Click(Sender: TObject);var AString: AnsiString; i: Integer;begin AString := ''; for i := 0 to 64 do AString := AString + Chr(i); Memo1.Lines.Text := SpecialCharsToHex(AString);end;produces:
--- Code: Text [+][-]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";}};} ---#0#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31 !"#$%&'() ....
(Lazarus 2.0.10/FPC 3.2.0 x86_64-Linux-gtk2)
dsiders:
--- Quote from: lucamar on November 03, 2020, 06:11:12 pm ---I can confirm. Something like:
--- 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";}};} ---procedure TForm1.Button1Click(Sender: TObject);var AString: AnsiString; i: Integer;begin AString := ''; for i := 0 to 64 do AString := AString + Chr(i); Memo1.Lines.Text := SpecialCharsToHex(AString);end;produces:
--- Code: Text [+][-]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";}};} ---#0#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31 !"#$%&'() ....
(Lazarus 2.0.10/FPC 3.2.0 x86_64-Linux-gtk2)
--- End quote ---
Thanks Lucamar.
Submitted: https://bugs.freepascal.org/view.php?id=38029
Bart:
Hmm, we could also extend Utf8EscapeControlChars() to do just that.
Bart
Navigation
[0] Message Index