Re: Convert from byte array to string
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 11/04/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Windows service accessing the network"
- Previous message: Bonj: "Windows service accessing the network"
- In reply to: Ricardo Quintanilla: "Re: Convert from byte array to string"
- Next in thread: Morten Wennevik: "Re: Convert from byte array to string"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 4 Nov 2004 10:42:44 -0500
Ricardo,
I understand, but you are using ASCII encoding. I also think that the
code page that you are using is wrong, and that is the case. Do you know
the code page of the machine that you are on that is processing the code?
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Ricardo Quintanilla" <RicardoQuintanilla@discussions.microsoft.com> wrote
in message news:16CAD5E1-C649-423C-8191-8CED363CD779@microsoft.com...
> First all, thanks Nicholas.
>
> i have no problem with the data sent to as400 socket, my problem is with
> the
> data received as response when i try to convert it from "byte array" to
> string, some characters are wrong converted.
>
> i am using the NetworkStream class in order to send/receive data over a
> TcpClient instance class.
>
> how can i apply your advice?
>
> --
> Ricardo Quintanilla G.
>
>
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>
>> Ricardo,
>>
>> It would seem to me that you are using the wrong encoding, or you
>> need
>> to specify the correct code page for the encoder. Are you sure that the
>> bytes being sent are ASCII encoded?
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@spam.guard.caspershouse.com
>>
>> "Ricardo Quintanilla" <RicardoQuintanilla@discussions.microsoft.com>
>> wrote
>> in message news:5C9EB410-9D3E-4A58-B635-CFDA1457B92F@microsoft.com...
>> >i have a code that sends data to a socket listening over as400 platform,
>> > the socket responds to me as a "byte array".
>> >
>> > then i need to convert the "byte array" into a string.
>> > the problem is that the data converted from the byte array into a
>> > string
>> > , is not what i expect.
>> >
>> > example:
>> > - the data returned from the socket is (byte array)
>> > "Usuario Sin Atribuciones Para Esta Función"
>> >
>> > - the data obtained from the convert process is (a string)
>> > "Usuario Sin Atribuciones Para Esta Funcisn"
>> >
>> > look at the last word, it have an accent, but when i convert it, the
>> > accent
>> > is loosed.
>> >
>> >
>> > i am using then next code, in order to convert the byte array to string
>> >
>> > -----------------------------------------------------------------------
>> > string dataReceivedinText =
>> > Encoding.ASCII.GetString(bytesDataReceived);
>> > -----------------------------------------------------------------------
>> >
>> > what can i do, in order to solve my problem?
>> > any suggestion?
>> >
>> > many thanks
>> >
>> >
>> > --
>> > Ricardo Quintanilla G.
>>
>>
>>
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Windows service accessing the network"
- Previous message: Bonj: "Windows service accessing the network"
- In reply to: Ricardo Quintanilla: "Re: Convert from byte array to string"
- Next in thread: Morten Wennevik: "Re: Convert from byte array to string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|