0

I have a sending sms website, and when any user sends a message having “ or such similar characters, it does not accept it and create problems, that this character is not allowed in GSM 7Bit class. Can you please explain, how to remove or translate such characters into valid ascii characters in c#.net. Fore example “ is "

Thanks

Muhammad Atif Agha
  • 1,535
  • 3
  • 33
  • 74

2 Answers2

2

Whenever you're taking the string and encoding it into bytes for sending, use Encoding.ASCII

James Manning
  • 13,429
  • 2
  • 40
  • 64
1

I guess the goal is to check if all characters of entered message are the member of GSM 7 bit encoding table.

public static boolean isGSM7Bit(String message)
{
Pattern pattern = Pattern.compile("^[A-Za-z0-9 \\r\\n@£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ!\"#$%&'()*+,\\-./:;<=>?¡ÄÖÑܧ¿äöñüà^{}\\\\\\[~\\]|€]*$");
Matcher matcher = pattern.matcher(message);
return matcher.matches();
}
Kemal Atik
  • 307
  • 3
  • 12