php - How to store/send language specific characters via XML -


i have system uses ajax send/receive information server(php). on server side, suppose 'store' following code xml , read , use on client:

<div id="somediv">Čiča gliša</div> 

the server gives no 'error' in logs, xml gets sent, on client side "not well-formatted" error when attempting read this.

the xml 'created' line (as far can tell, not back-end dev, wouldn't proficient these things, 'content' causing issue time tasked resolving it.

$this->xml = new simplexmlelement('<?xml version="1.0" encoding="utf-8"?><xml/>') 

when change letters Č , Š c , s works. dont know how make work otherwise.

using mozzila on client if matters, freshly installed.

edit: xml requested in comments
(if managed debug properly)
response:

<?xml version="1.0" encoding="utf-8"?> <xml>     <client_contents>     <frame>         <![cdata[             <div id="upper">upper div</div><br>             <div id="middle">middle</div><br>             <div id="lower">lower div <br>             <a onclick="executescenario('post',6,1);">run something</a></div>         ]]>     </frame>         <upper>             <![cdata[                 <div class="col-lg-4 col-md-5 col-sm-6 col-xs-10 col-lg-offset-7 col-md-offset-6 col-sm-offset-5  col-xs-offset-1 info-content">                                     <div class="row title">                         <h2>naziv turisti?kog objekta</h2>                     </div>                                     <div class="one-info">                         <div class="icon">                             <span class="glyphicon glyphicon-home"></span>                         </div>                         <div class="data">                             <p>ulica cica gli�e 15</p>                             <p>11215 donji svrd�ibrd�ilovci</p>                         </div>                     </div>                 </div>             ]]>         </upper>         <middle>             <![cdata[                 <div> menu </div>             ]]>         </middle>     </client_contents> <data_sets> <data> </data> </data_sets> <java_scripts/> </xml> 

what did notice there closing tag, without ever being opening one, though not seem cause of error because remove characters Č thing starts working.

apparently issue lies fact string has converted before sent xml. string written in editor, such netbeans has kind of encoding (windows-1252) in case, , if such string passed xml, regardless of xml's encoding, interpreted wrong.

because [[cdata]] eat anything, keeps string is, when client receieves data, assumes encoding utf-8 (because says in xml), in fact string in there not utf-8, windows-1252 (which developer enviroment uses).

tl;dr

iconv('windows-1252', 'utf-8', $string); //current, wanted, string 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -