65.9K
CodeProject is changing. Read more.
Home

Decoding the "Windows 1255" format

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.14/5 (6 votes)

May 11, 2009

CPOL
viewsIcon

31974

downloadIcon

170

An article on how to decode the "Windows 1255" format.

Decode Method

Introduction

This article solves the problem of decoding the Windows 1255 encoding.

Background

Usually, when you get Hebrew emails, the subject line is encoded in a strange way. After reading a lot of articles on the subject, I decided to rollout a decoding version of my own, which handles Base64 and plain encoding of Hebrew messages.

Using the Code

Instantiate the class with the text to decode, and use the Decode method. The static property IsWindows1255 can determine if the text is actually encoded to avoid the exception thrown by the constructor (when given a non-encoded text).

Like this:

if (Windows1255Helpers.IsWindows1255(ret))
{
    Windows1255Helpers helper = new Windows1255Helpers(ret);
    ret = helper.Decode();
}

If you have further questions, don't hesitate to send a mail. And furthermore, you can visit me (and my friends!) at our blog.

Points of Interest

I have read some specifications regarding encoding or decoding of MIME messages and subjects, and if I have missed something, please feel free to remark.

And please excuse my English if there are mistakes; I'm from Israel, and English is not my primary language.... :)

History

  • First version - 11.5.2009.