RiaanDP
RiaanDP

Reputation: 1222

Convert extended ASCII character codes to ISO-8859-1

I am in the process of porting data from a legacy system, but I am unsure what encoding it uses internally to store the data. I have noticed that the data corresponds to ASCII code values (i.e. character ë, or small letter e with diaeresis, is stored as byte value 137 as per this chart).

I need to encode the data using ISO-8859-1 for the destination system, but obviously using the data as-is yields the incorrect results (in ISO-8859-1 the per mille sign is represented by decimal 137, as per this chart).

I need some advice on what encoding I can use when reading the data - i.e. an encoding that corresponds to the decimal ASCII code values.

Upvotes: 1

Views: 896

Answers (1)

RiaanDP
RiaanDP

Reputation: 1222

I found my answer in this SO post. It turns out that code page 437 corresponds to the extended ASCII character codes. I was thus able to re-encode the data as follows:

var output = Encoding.Convert(Encoding.GetEncoding(437), Encoding.GetEncoding("ISO-8859-1"), input);

Upvotes: 1

Related Questions