Determine if a string only contains characters from the seven bit alphabet(c#)
I'm developing an sms application in c#. The service that I use to send a message only allows characters form the 7 bit alphabet. I'm looking for a way to check if a message only contains characters from this alphabet.
My first idea was to split the message into a character array and then loop these characters and compare them to the alphabet. But I bet there is a much better开发者_如何学Python.
7 big alphabet: http://www.dreamfabric.com/sms/default_alphabet.html
You can find a utility GSM Encoding class (it simply derives from the abstract System.Text.Encoding) defined here: The GSM character set in .NET. I think this is the most elegant and reusable way.
I think you need to determine the encoding of input text look at the Encoding class
精彩评论