Looking for a list of valid characters that can be

2019-01-23 05:11发布

I've been working with an SMS aggregator's web api to send and receive text messages. Not all characters are valid, and when I attempt to send a message with, say, a hash mark # it fails.

I need to clean the strings before I send them but I cannot find a valid list of what characters are good. Mr. Google isn't much help - maybe i'm looking for the wrong terms.

I have already scoured the api manual, and have emailed the company with my question, but there are no answers.

I expect that different phones can handle different lists of characters... eg an iPhone should handle a wide range of characters, but my old nokia flip phone will probably only handle a couple dozen characters beyond the alphanumeric. I'll need the lowest common denominator.

标签: sms character
2条回答
贪生不怕死
2楼-- · 2019-01-23 05:27

This depends on your aggregator. Default sms charset is limited to latin and some special letters only (including hash mark), others are sent in unicode or using locking shift table mechanism. But you are using an api to send messages, so all these things are incapsulated. I suggest continuing asking your aggregator for help, probably they block some characters manually.

查看更多
等我变得足够好
3楼-- · 2019-01-23 05:33

This is built entirely off of @vissi's answer, but this is something you should be able to plug in if you want to build a small collection into your application for verification purposes.

// Standard Latin Characters
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',

// Numbers
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',

// Punctuation
'!', '#', ' ', '"', '%', '&', '\'', '(', ')', '*', ',', '.', '?',
'+', '-', '/', ';', ':', '<', '=', '>', '¡', '¿', '_', '@',

// Currency
'$', '£', '¥', '\u00A4', // [UNTYPED] CURRENCY SIGN

// Accented Characters
'è', 'é', 'ù', 'ì', 'ò', 'Ç', 'Ø', 'ø', 'Æ', 'æ', 'ß', 'É', 'Å',
'å', 'Ä', 'Ö', 'Ñ', 'Ü', '§', 'ä', 'ö', 'ñ', 'ü', 'à',

// Greek Characters
'\u0394', // GREEK CAPITAL LETTER DELTA
'\u03A6', // GREEK CAPITAL LETTER PHI
'\u0393', // GREEK CAPITAL LETTER GAMMA
'\u039B', // GREEK CAPITAL LETTER LAMBDA
'\u03A9', // GREEK CAPITAL LETTER OMEGA
'\u03A0', // GREEK CAPITAL LETTER PI
'\u03A8', // GREEK CAPITAL LETTER PSI
'\u03A3', // GREEK CAPITAL LETTER SIGMA
'\u0398', // GREEK CAPITAL LETTER OMEGA
'\u039E', // GREEK CAPITAL LETTER XI

// Other Miscellaneous Characters
'\u001B', // ESCAPE
    '\n', // NEW LINE or LINE FEED
    '\r'  // CARRIAGE RETURN
查看更多
登录 后发表回答