Jump to content
Sign in to follow this  
omnibrain

Doscommand OnCharDecoding Output

Recommended Posts

I'm currently experimenting with Turbopack DosCommand and try to capture the following output for the "ping" command. (ping is just an example I try with)

Ping wird ausgeführt für 8.8.8.8 mit 32 Bytes Daten:

But the DosCommand doesn't seem to decode the output right:

Ping wird ausgef�hrt f�r 8.8.8.8 mit 32 Bytes Daten:

I tried to implement the CharDecoding event to decode the output for Unicode

function TForm4.DosCommand1CharDecoding(ASender: TObject;
  ABuf: TStream): string;
var pBytes: TBytes;
  iLength: integer;
begin
  ilength := ABuf.Size;
  if iLength > 0 then
  begin
    SetLength(pBytes, iLength);
    ABuf.Read(pBytes, iLength);
    Result := TEncoding.Unicode.GetString(pBytes);
  end
  else
    Result := '';
end;

but I only get chineese characters as a result:

਍楐杮眠物⁤畡杳晥梁瑲映犁㠠㠮㠮㠮業⁴㈳䈠瑹獥䐠瑡湥ഺ湁睴牯⁴潶⸸⸸⸸㨸祂整㵳㈳娠楥㵴㐲獭吠䱔ㄽ㔱਍湁睴牯⁴潶⸸⸸⸸㨸祂整㵳㈳娠楥㵴㐲獭呔㵌ㄱവ湁睴牯⁴潶⸸⸸⸸㨸祂整㵳㈳娠楥㵴㈲獭吠䱔ㄽ㔱਍湁睴牯⁴潶⸸⸸⸸㨸祂整㵳㈳娠楥㵴㈲獭吠䱔ㄽ㔱਍਍楐杮匭慴楴瑳歩映犁㠠㠮㠮㠮ഺ †倠歡瑥㩥䜠獥湥敤⁴‽ⰴ䔠灭慦杮湥㴠㐠‬敖汲牯湥㴠〠਍††〨‥敖汲獵⥴ബ慃‮敚瑩湡慧敢湩䴠汩楬敳⹫ഺ †䴠湩浩浵㴠㈠洲ⱳ䴠硡浩浵㴠㈠洴ⱳ䴠瑩整睬牥⁴‽㌲獭਍

 

Share this post


Link to post

What is the result when doing it this way?

TEncoding.ANSI.GetString(pBytes)

 

Share this post


Link to post

Can you attach the binary stream content here?

Share this post


Link to post
(13, 10, 80, 105, 110, 103, 32, 119, 105, 114, 100, 32, 97, 117, 115, 103, 101, 102, 129, 104, 114, 116, 32, 102, 129, 114, 32, 56, 46, 56, 46, 56, 46, 56, 32)

This is the value from "pbytes" from the watchlist.

 

#$D#$A'Ping wird ausgef'#$0081'hrt f'#$0081'r 8.8.8.8 '

is the result after "TEncoding.ANSI.GetString"

Share this post


Link to post

Seems your command window uses codepage 850:

 

  var encoding := TMBCSEncoding.Create(850);
  try
    Result := encoding.GetString(pBytes);
  finally
    encoding.Free;
  end;

 

Share this post


Link to post
Posted (edited)
5 hours ago, Uwe Raabe said:

Seems your command window uses codepage 850:

Thanks, that worked.

The joys of windows legacy and eternal backwards compatibility...

Edited by omnibrain
  • Haha 1

Share this post


Link to post

So Germans have OEM encoding as well! Not only non-latin locales still pulling that old-time mess

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×