Try Decoder.GetChars then StringBuilder.Append, ToString. Make sure you remove any BOM if present.
-Jeff WS -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Fernando Tubio Sent: Thursday, September 25, 2003 2:59 PM To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Binary data to string representation of hex values There is also BitConverter.ToString( byte[] value ). Unfortunately, this method returns a string with each hexadecimal pair separated by hyphens (e.g. 2A-1B-AA) which is almost invariably NOT what I need. But maybe it will do for you. Regards, Fernando Tubio ----- Original Message ----- From: "Adam Straughan" <[EMAIL PROTECTED]> Sent: Wednesday, September 24, 2003 7:18 AM Subject: Re: Binary data to string representation of hex values > Assuming that I understand > > byte b[] = new byte[]{0,10}; > string s = ""; > for(int i=0 ; i < b.Length ; i++) > s=b[i].ToString("X") + s; > > adam > > Randy Collins wrote: > > I am calling a 3rd party win32 api function that is returning binary > > data from a mainframe into a StringBuilder type parameter. This > > function also takes a length parameter to tell it how big the > > StringBuilder buffer is. > > > > My question is, how to I format this binary data as a hex string? > > That is, if the buffer contains two bytes, a binary 0 and a binary > > 10 (decimal), I return "0A". > > > > Thanks > > > > =================================== > > This list is hosted by DevelopMentor(r) http://www.develop.com NEW! > > ASP.NET courses you may be interested in: > > > > 2 Days of ASP.NET, 29 Sept 2003, in Redmond > > http://www.develop.com/courses/2daspdotnet > > > > Guerrilla ASP.NET, 13 Oct 2003, in Boston > > http://www.develop.com/courses/gaspdotnet > > > > View archives and manage your subscription(s) at > > http://discuss.develop.com > > =================================== > This list is hosted by DevelopMentorR http://www.develop.com NEW! > ASP.NET courses you may be interested in: > > 2 Days of ASP.NET, 29 Sept 2003, in Redmond > http://www.develop.com/courses/2daspdotnet > > Guerrilla ASP.NET, 13 Oct 2003, in Boston > http://www.develop.com/courses/gaspdotnet > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentorR http://www.develop.com NEW! ASP.NET courses you may be interested in: 2 Days of ASP.NET, 29 Sept 2003, in Redmond http://www.develop.com/courses/2daspdotnet Guerrilla ASP.NET, 13 Oct 2003, in Boston http://www.develop.com/courses/gaspdotnet View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor� http://www.develop.com NEW! ASP.NET courses you may be interested in: 2 Days of ASP.NET, 29 Sept 2003, in Redmond http://www.develop.com/courses/2daspdotnet Guerrilla ASP.NET, 13 Oct 2003, in Boston http://www.develop.com/courses/gaspdotnet View archives and manage your subscription(s) at http://discuss.develop.com
