php - iconv(): Detected an illegal character in input string -


i using iconv function convert string requested character encoding. on below code

$sms_text =  'a:'f3*'f'; // output received smpp $result = iconv('utf-16be' ,'utf-8//ignore' , $sms_text); echo 'ignore: ' .$result;  echo $sms_text = iconv('utf-16be' ,'utf-8' , $sms_text);  $result1 = iconv('utf-16be' ,'utf-8//translit' , $sms_text); //line no (53) echo 'transilt: '.$result1; 

and received below output enter image description here
if have string of dari , pashto language, showing first word , dont return remaining string after blank space. //ignore gives same output.

should replace these blank spaces of other character can complete string?

note: passing string received smpp(receiver).

sms sent smpp : افغانستان کابل outpur received smpp : 'a:'f3*'f string converted iconv : افغانستان  

english string working well.

thanks in advance.

you converting string utf-8 charset on line:

echo $sms_text = iconv('utf-16be' ,'utf-8' , $sms_text); 

the error appears becouse trying convert second time. resolve issue should not update $sms_text variable on mentioned line.

here code , output works me:

$sms_text ="فغانستان کابل";  echo "utf-8 : $sms_text \n";  $sms_text = iconv('utf-8', 'utf-16be', $sms_text);  echo "utf-16be : $sms_text \n";  echo 'ignore: ' . iconv('utf-16be' ,'utf-8//ignore' , $sms_text) . "\n"; echo 'simple: ' . iconv('utf-16be' ,'utf-8' , $sms_text) . "\n"; echo 'transilt: '. iconv('utf-16be' ,'utf-8//translit' , $sms_text) . "\n"; 

output:

utf-8 : فغانستان کابل  utf-16be : a:'f3*'f ignore: فغانستان کابل simple: فغانستان کابل transilt: فغانستان کابل 

as blank spaces, please share test string?


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -