omnibrain 15 Posted June 9, 2022 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
Uwe Raabe 2064 Posted June 9, 2022 What is the result when doing it this way? TEncoding.ANSI.GetString(pBytes) Share this post Link to post
omnibrain 15 Posted June 9, 2022 18 minutes ago, Uwe Raabe said: What is the result when doing it this way? TEncoding.ANSI.GetString(pBytes) Same as without event handler, which is no surprise, as "TEncoding.ANSI" is the default in the DosCommand Unit. https://github.com/TurboPack/DOSCommand/blob/4ded41648e4e1aafa372c7a740fb2366aeb3e9e4/Source/DosCommand.pas#L1042 Share this post Link to post
Uwe Raabe 2064 Posted June 9, 2022 Can you attach the binary stream content here? Share this post Link to post
omnibrain 15 Posted June 9, 2022 (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
Uwe Raabe 2064 Posted June 9, 2022 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
omnibrain 15 Posted June 9, 2022 (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 June 9, 2022 by omnibrain 1 Share this post Link to post
Fr0sT.Brutal 900 Posted June 10, 2022 So Germans have OEM encoding as well! Not only non-latin locales still pulling that old-time mess Share this post Link to post