Login   Register  
PHP Classes
elePHPant
Icontem

How to send special chars?

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      SMPP Class  >  All threads  >  How to send special chars?  >  (Un) Subscribe thread alerts  
Subject:How to send special chars?
Summary:How to send special chars (as €, á, é,...) without using unicode
Messages:2
Author:José Carlos Cruz Parra
Date:2009-02-22 12:16:18
Update:2009-04-28 08:14:51
 

  1. How to send special chars?   Reply   Report abuse  
Picture of José Carlos Cruz Parra
José Carlos Cruz Parra
2009-02-22 12:16:18
Hi,

I need to send chars as € (euro), á (aacute),... without using unicode because when I use unicode message maxlength becomes much shorter than initial 160 chars, so one message is splitted in two or more messages, and that has a cost.

Is there any solution? The only way I found is to replace those chars before sending the message, for example: € replace with E, á replace with a

Thank you a lot.

  2. Re: How to send special chars?   Reply   Report abuse  
Picture of Suartana
Suartana
2009-04-28 08:14:51 - In reply to message 1 from José Carlos Cruz Parra
Hi,

You should using converter from ISO or UTF8 to GSM characterset.
Here is the example from me.

# set class
class GsmCharacterSetConverter {

# public member area
#**************************************************
# convert iso to gsm character *
# @param string *
# @return string *
# $this->onvertCharacters($string) *
#***************************************************

public function convertCharacters($string) {
# set iso latin 1 to gsm character in array
$iso8859ToGsmCharacterSet = array (

0x0a => 0x0a, 0x0d => 0x0d, 0x20 => 0x20, 0x21 => 0x21, 0x22 => 0x22,
0x23 => 0x23, 0x24 => 0x02, 0x25 => 0x25, 0x26 => 0x26, 0x27 => 0x27,
0x28 => 0x28, 0x29 => 0x29, 0x2a => 0x2a, 0x2b => 0x2b, 0x2c => 0x2c,
0x2d => 0x2d, 0x2e => 0x2e, 0x2f => 0x2f, 0x30 => 0x30, 0x31 => 0x31,
0x32 => 0x32, 0x33 => 0x33, 0x34 => 0x34, 0x35 => 0x35, 0x36 => 0x36,
0x37 => 0x37, 0x38 => 0x38, 0x39 => 0x39, 0x3a => 0x3a, 0x3b => 0x3b,
0x3c => 0x3c, 0x3d => 0x3d, 0x3e => 0x3e, 0x3f => 0x3f, 0x40 => 0x00,
0x41 => 0x41, 0x42 => 0x42, 0x43 => 0x43, 0x44 => 0x44, 0x45 => 0x45,
0x46 => 0x46, 0x47 => 0x47, 0x48 => 0x48, 0x49 => 0x49, 0x4a => 0x4a,
0x4b => 0x4b, 0x4c => 0x4c, 0x4d => 0x4d, 0x4e => 0x4e, 0x4f => 0x4f,
0x50 => 0x50, 0x51 => 0x51, 0x52 => 0x52, 0x53 => 0x53, 0x54 => 0x54,
0x55 => 0x55, 0x56 => 0x56, 0x57 => 0x57, 0x58 => 0x58, 0x59 => 0x59,
0x5a => 0x5a, 0x5f => 0x11, 0x61 => 0x61, 0x62 => 0x62, 0x63 => 0x63,
0x64 => 0x64, 0x65 => 0x65, 0x66 => 0x66, 0x67 => 0x67, 0x68 => 0x68,
0x69 => 0x69, 0x6a => 0x6a, 0x6b => 0x6b, 0x6c => 0x6c, 0x6d => 0x6d,
0x6e => 0x6e, 0x6f => 0x6f, 0x70 => 0x70, 0x71 => 0x71, 0x72 => 0x72,
0x73 => 0x73, 0x74 => 0x74, 0x75 => 0x75, 0x76 => 0x76, 0x77 => 0x77,
0x78 => 0x78, 0x79 => 0x79, 0x7a => 0x7a, 0xa1 => 0x40, 0xa3 => 0x01,
0xa4 => 0x24, 0xa5 => 0x03, 0xa7 => 0x5f, 0xb6 => 0x16, 0xbf => 0x60,
0xc4 => 0x5b, 0xc5 => 0x0e, 0xc6 => 0x1c, 0xc7 => 0x09, 0xc9 => 0x1f,
0xd1 => 0x5d, 0xd6 => 0x5c, 0xd8 => 0x0b, 0xdc => 0x5e, 0xdf => 0x1e,
0xe0 => 0x7f, 0xe4 => 0x7b, 0xe5 => 0x0f, 0xe6 => 0x1d, 0xe8 => 0x04,
0xe9 => 0x05, 0xec => 0x07, 0xf1 => 0x7d, 0xf2 => 0x08, 0xf6 => 0x7c,
0xf8 => 0x0c, 0xf9 => 0x06, 0xfc => 0x7e,
);
# extended table iso
$extendedTableIso8859ToGsm = array (
0x5e => 0x14, // ^
0x7b => 0x28, // {
0x7d => 0x29, // }
0x5c => 0x2f, // \
0x5b => 0x3c, // [
0x7e => 0x3d, // ~
0x5d => 0x3e, // ]
0x7c => 0x40, // |
0x80 => 0x65, // �
);
# enxtended alpabet character
$EXTENDED_ALPHABET_CHARACTER = 0x1B;
# converting table
$characterConvertingTable = $iso8859ToGsmCharacterSet;
$returnValue = "";
# listing characterset
for ($i=0; $i < strlen($string); $i++) {
$character = substr($string, $i, 1);
$value = -1;
if ( array_key_exists( ord($character), $characterConvertingTable ) ) {
$value = $characterConvertingTable[ord($character)];
}
else {
$value = 0x20; // insert a space character for not supported characters
}
if (!$fromGsmToAscii) {
// ascii to gsm
if ( array_key_exists( ord($character), $extendedTableIso8859ToGsm ) ) {
$returnValue .= chr($EXTENDED_ALPHABET_CHARACTER).
chr($extendedTableIso8859ToGsm[ord($character)]);
$value = -1; // don't append anything else afterwards
}

}
if ($value != -1) {
$returnValue .= chr($value);
}
}
return $returnValue;
}

#***************************************************
# set ascii to gms character function *
# @param string *
# @return string *
# $this-> asciiToGsm($String) *
#***************************************************
public function asciiToGsm($String) {
return( $this->convertCharacters($String) );
}



}