decoding byte array

decoding byte array

am 23.11.2007 02:32:00 von Paul

how do i decode a byte array using getstring, if i don't know which encoding
was used to write it?

Re: decoding byte array

am 23.11.2007 07:07:04 von mattias.dont.want.spam

>how do i decode a byte array using getstring, if i don't know which encoding
>was used to write it?

That would be pretty hard to do if there's no BOM or other indicator.
You'd probably have to try to figure it out one way or another.

The Windows API offers the function IsTextUnicode which does some
guessing about whether or not a string is in a unicode format or not,
but it's not perfect.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: decoding byte array

am 23.11.2007 07:52:01 von Paul

ok thanks

"Mattias Sjögren" wrote:

> >how do i decode a byte array using getstring, if i don't know which encoding
> >was used to write it?
>
> That would be pretty hard to do if there's no BOM or other indicator.
> You'd probably have to try to figure it out one way or another.
>
> The Windows API offers the function IsTextUnicode which does some
> guessing about whether or not a string is in a unicode format or not,
> but it's not perfect.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>

Re: decoding byte array

am 23.11.2007 10:02:44 von lasse

..paul. wrote:
> how do i decode a byte array using getstring, if i don't know which encoding
> was used to write it?

Is there no way of changing the problem to "how do I guarantee that I
know what the encoding is"?

--
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/