Recent

Author Topic: [SOLVED] StringToHex might not return a result  (Read 926 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
[SOLVED] StringToHex might not return a result
« on: August 11, 2023, 08:22:34 pm »
packages/fcl-hash/src/fphashutils.pp has the following function
Code: Pascal  [Select][+][-]
  1. function StringToHex(const s: ansistring): ansistring;
  2. begin
  3.   if s='' then exit;
  4.   BytesToHexStr(Result,@s[1],length(s));
  5. end;
The code of this function might not assign a result.
« Last Edit: August 12, 2023, 01:26:47 pm by lagprogramming »

domasz

  • Sr. Member
  • ****
  • Posts: 455
Re: StringToHex might not return a result
« Reply #1 on: August 11, 2023, 08:28:17 pm »
Seems someone forgot 3 chars
Code: Pascal  [Select][+][-]
  1.     function StringToHex(const s: ansistring): ansistring;
  2.     begin
  3.       if s='' then exit(s);
  4.       BytesToHexStr(Result,@s[1],length(s));
  5.     end;
« Last Edit: August 11, 2023, 08:30:03 pm by domasz »

lagprogramming

  • Sr. Member
  • ****
  • Posts: 406
Re: StringToHex might not return a result
« Reply #2 on: August 11, 2023, 08:33:15 pm »
Seems someone forgot 3 chars
Code: Pascal  [Select][+][-]
  1.     function StringToHex(const s: ansistring): ansistring;
  2.     begin
  3.       if s='' then exit(s);
  4.       BytesToHexStr(Result,@s[1],length(s));
  5.     end;
Maybe 4: :-\ exit('');
Edit: Should this function be allowed to return an empty string?  :-\ We'll see.
« Last Edit: August 11, 2023, 08:36:33 pm by lagprogramming »

Thaddy

  • Hero Member
  • *****
  • Posts: 14659
  • Sensorship about opinions does not belong here.
Re: StringToHex might not return a result
« Reply #3 on: August 11, 2023, 08:38:57 pm »
That is flawed indeed, use syutils and the helper ToHexString.
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

AlexTP

  • Hero Member
  • *****
  • Posts: 2421
    • UVviewsoft

 

TinyPortal © 2005-2018