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
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