简体   繁体   English

适用于GSM Pdu 7Bit的文本编码,以避免像“Pdu 7Be”这样的字符

[英]Proper text encoding for GSM Pdu 7Bit to avoid chars like “

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. 我有一个发送短信网站,并且当任何用户发送具有“或类似字符的消息,它不接受它并产生问题时,在GSM 7Bit类中不允许该字符。 Can you please explain, how to remove or translate such characters into valid ascii characters in c#.net. 你能解释一下,如何删除或翻译这些字符到c#.net中的有效ascii字符。 Fore example “ is " 前例“是”

Thanks 谢谢

无论何时你拿字符串并将其编码为字节进行发送,都要使用Encoding.ASCII

I guess the goal is to check if all characters of entered message are the member of GSM 7 bit encoding table. 我想目标是检查输入消息的所有字符是否是GSM 7位编码表的成员。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM