替换GSM的无效字符 [英] Replacing invalid characters for GSM

查看:87
本文介绍了替换GSM的无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在向客户发送自动短信,因为我们希望将短信的数量保持在最低限度,并避免使用UCS发送短信-2编码我正在寻找一种方法来替换GSM中具有类似字符的字符。



例如拉长的连字符 - ,我想用 - 标准连字符。



我只是想知道是否有一些东西我可以用来转换它而不会得到很多无效字符或只是删除它们并在其中放入空格。



任何人都知道任何可以做到这一点的事情吗?



否则我想我会有做一些事情。



问候

Carl

Hi,

I am sending automated sms messages to customers and as we would like to keep the amount of sms sent to a minimum and avoid sending them with UCS-2 encoding i was looking for a way to replace the characters that arnt in GSM with similar characters.

For instance elongated hyphens — , i would like to replace these with - standard hyphens.

I was just wondering if there was a something i could use to convert it without getting lots of invalid characters or just removing them and putting blank spaces in.

Anyone know of anything that can do the trick?

Otherwise i guess i'll have to make something that does it.

Regards
Carl

推荐答案

我不知道有一个库可以做到这一点,虽然如果你还没有,它绝对值得搜索。它写得很简单,你需要的只是用你不喜欢的字符和想要替换它的字符重复调用 string.Replace (例如 text = text.Replace (' - ',' - '))然后,当你完成了你所知道的所有替换后,请仔细检查字符串并替换任何对GSM无效的字符(不确定是什么)但我猜ANSI-256?)有一个占位符,比如'_'或'?'。
I'm not aware of a library that does this, although it's definitely worth a search if you haven't already. It's simple enough to write, all you need is to call string.Replace repeatedly with the character you don't like and the one you want to replace it with (e.g. text = text.Replace('–', '-')) and then, when you've done all the replacements you know about, go through the string and replace any characters that aren't valid for GSM (not sure what that is but I guess ANSI-256?) with a placeholder, like '_' or '?'.


我已经把它全部放在自己的路上了,这似乎是没有库的唯一解决方案可供我使用。



这几乎没有任何代码,但是花了几个繁琐的时间才发现哪些角色在GSM中交换并交换它们在适当的地方。



感谢BobJanova的回复。
I've gone down the route of putting it all in myself, that seems to be the only solution with no library available to do it for me.

It's hardly any code but it took a couple of tedious hours finding which characters arnt in GSM and swapping them out where appropiate.

Thanks for the response BobJanova.


这篇关于替换GSM的无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆