XML UTF8 Encoding problem.

oracle

New Member
Messages
430
Reaction score
0
Points
0
Hi,

I am getting the following error.

Can someone suggest how can I by pass this ??

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 7: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xAD 0x4B 0x72 0x69 in C:\Workspace\addressbook.php on line 58

Warning: simplexml_load_string() [function.simplexml-load-string]: <contact name="�Kriti S �Das" email="iitgkriti@gmail.com" /> in C:\Workspace\addressbook.php on line 58

Line 58 reads as:
$xml = simplexml_load_string($str);

Thanx in advance,
Imoracle
 

oracle

New Member
Messages
430
Reaction score
0
Points
0
No I put an example from my local machine, else on server its not the same way......

Any HELP PLZZZZZZZ
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
Is the string encoded as UTF-8? If not, try this: $xml = simplexml_load_string(utf8_encode($str));
 

oracle

New Member
Messages
430
Reaction score
0
Points
0
solved the issue with mb string thingy :)
Edit:
Well seems some problem again :(

Thr r still a few contacts in the users contact book which are causing problem ... :(

for eg. here :

ontact name="�Kriti S �Das" email="iitgkriti@gmail.com

Can someone tell me a solution ?
 
Last edited:

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
Using utf-8 can be a pain, I know because I had to do it for my website. Here are some steps that you can take.
  1. Make sure that the "mbstring.internal_encoding" is set to "utf-8" in your php.ini file.
  2. Make sure that you pages html is set to utf-8. "<meta http-equiv="Content-Type" content="text/html; charset=utf-8">". Make sure that it isn't automatically set to some other encoding. You need to set the XML encoding in this case.
  3. Finally you will need to make sure that you aren't giving php characters which are multibyte such as 'è' in the wrong encoding. This is the most anouying part because even if you have copied the character into a document, an os such as xp will automatically convert it into some other encoding. I suggest putting in the actual html codes and then running the html_entity_decode() function.
If you are going to use utf-8 on x10 then I suggest that you put this code at the beginning of every one of your .php files that will use mb.string because this sets it up properly.
PHP:
        ini_set  ("mbstring.language" , "Neutral");
        ini_set  ("mbstring.internal_encoding" , "UTF-8");
        ini_set  ("mbstring.detect_order" , "auto");
        ini_set  ("mbstring.http_input" , "pass");
        ini_set  ("mbstring.http_output" , "pass");
        ini_set  ("mbstring.encoding_translation" , "off");
 
Last edited:
Top