Monday, 29 September 2014

clean xml tweet from unknown characters with action script



I'm reading tweets via xml format depending on hashtags,


however, I'm encountering some strange characters in tweets which are causing me troubles. example: 😭😭😭😭😭😭😭😭😭😭😭😭😭😭😭😭


I managed to fix it with php with this code i found online:



$thetweet = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
'|[\x00-\x7F][\x80-\xBF]+'.
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
'?', $thetweet );


however, this regular expression does not work in action script 3. can anyone help applying this code in action script? it's not accepting this regex.


thanks in advance


No comments:

Post a Comment