简体   繁体   中英

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. Can you please explain, how to remove or translate such characters into valid ascii characters in c#.net. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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