encoding always gets defaultencoder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a very common problem. I try to change my encoding from
defaultencoding (UTF-16) to iso-8859-15.
My source:

Encoding encoder = Encoding.GetEncoding("iso-8859-15");
log.logDebug("Encoding is " + encoder.GetEncoder());
byte[] byteArray = new byte[buffer.Length];
byteArray = encoder.GetBytes(buffer);

the logging output:

Encoding is System.Text.Encoding+DefaultEncoder

Does anybody has an idea. I would appreciate it.

Marco
 
Hi Marco,

I'm not too familiar with the Encoder class, but I believe it is created
based on the number of bytes needed to define a character in a certain
Encoding, so any of the 8-bit encodings like "ISO-8859-15" would create an
Encoder of default type.
 
Marco,

System.Text.Encoding.GetEncoding(437).GetBytes()

I don't know what thable that 8859 is I thought 1252

Cor
 
Hi Cor,

tried this already. But it doesn't matter which parameter I pass the method
GetEncoding(), I always become the Default- Encoder.

Some parametervalues I used: "ISO-8859-15", 1252, 437

Marc
 
What are you trying to accomplish?


Hi Cor,

tried this already. But it doesn't matter which parameter I pass the
method
GetEncoding(), I always become the Default- Encoder.

Some parametervalues I used: "ISO-8859-15", 1252, 437

Marc
 
Marco said:
I have a very common problem. I try to change my encoding from
defaultencoding (UTF-16) to iso-8859-15.
My source:

Encoding encoder = Encoding.GetEncoding("iso-8859-15");
log.logDebug("Encoding is " + encoder.GetEncoder());
byte[] byteArray = new byte[buffer.Length];
byteArray = encoder.GetBytes(buffer);

the logging output:

Encoding is System.Text.Encoding+DefaultEncoder

Does anybody has an idea. I would appreciate it.

That's giving the right encoder - it's just implemented by a class
called DefaultEncoder nested inside Encoding.
 
Back
Top