"sippyuconn" <si********@newsgroup.nospamwrote in message
news:A5**********************************@microsof t.com...
Hi
I have a project to take a MS Word doc and reformat the text into text
files
that are
built into my App.
The only issue I have is some time there are some characters in MS Word
that
are not printable when viewed in Notepad. I usually catch by looking at
the
text in my App. Usually the problem is
an extra long hyphen --
a dagger +
Usually when I debug the string I see a squareblock in the string
Is there someway to trap the characters that will be not
printable/viewable
in say notepad????
You need to use an Encoding object obtained via the Encoding.GetEncoding
static method. This method allows you to specify the EncoderFallBack class
to use (this defaults to the EncoderReplacementFallback which simply
replaces un-encodable chars with ?).
By supplying the EncoderExceptionFallback object instead then when using the
Encoding to convert your content any out-of-band characters will cause an
EncoderFallbackException to be thrown.
The EncoderFallbackException has properties that you can use to discover
what character caused the problem and where it is.
--
Anthony Jones - MVP ASP/ASP.NET