Defining if the character is printable or not

  • Thread starter Thread starter alexttp
  • Start date Start date
A

alexttp

I am trying to make sure that - when saving some XML - only the
printable characters are saved "as is" - and all the rest would be
converted into their "&#x{0};" representation.

Years ago ;-) there was an IsPrintable() function, but it is not
present in C# Char class implementation.

So for this purpose I check the character with:
1. Char.IsSurrogate() - to check if the character is one of multibyte
letter bytes (such bytes will be treated as unprintable, right?)
2. Char.IsLetterOrDigit() || Char.IsPunctuation() ||
Char.IsSeparator() || Char.IsWhiteSpace(). If any of these is true -
the character is considered to be printable. Any other is unprintable.

Do I miss anything? Unicode stuff? Multibyte?...

Please note that I'd like to make sure that any globalization is
preserved, meaning different codepages/encodings support.

Thanks a lot for any useful input!

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top