Jump to content

[SOLVED] Problem encodage ACSII


vik93

Recommended Posts

Hello !

 

I have a little problem. When I'm trying to add a product using webservice, it is impossible.

 

It is bloking with French accents (à, é, è, ç, etc...).

 

The original XML is in UTF-8, but when the script is reading adding this document, it is giving the ACSII instead of UTF-8.

 

And webservice is not accepting ASCII  :-(

 

XML SENT
xml=<?xml version="1.0"?>
<prestashop>
<product>
<reference> OC250B </reference>
<stock_availables node_type="stock_available"/>
<id_category_default>2</id_category_default>
<id_category>2</id_category>
<redirect_type>404</redirect_type>
<available_for_order>1</available_for_order>
<show_price>1</show_price>
<minimal_quantity>1</minimal_quantity>
<active>0</active>
<price required="true" format="isPrice">5.770</price>
<id_tax_rules_group format="isUnsignedId">1</id_tax_rules_group>
<name required="true" maxSize="128" format="isCatalogName">
<language id="1">Bol salade à charnière R250</language>
</name>
<link_rewrite required="true" maxSize="128" format="isLinkRewrite">
<language id="1" format="isUnsignedId">Bol-salade-à-charnière-R250</language>
</link_rewrite>
<associations>
<categories>
<category>2</category>
</categories>
<tags><tag><id>1</id></tag>
</tags>
<product_features><product_feature><id>8</id><custom>0</custom><id_feature_value>38</id_feature_value></product_feature><product_feature><id>9</id><custom>0</custom><id_feature_value>83</id_feature_value></product_feature>
</product_features>
</associations>
</product>
</prestashop>

We can see for the Name and Link_rewrite balise that it is taking ASCII

 

RETURN HTTP BODY

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[127]]></code>
<message><![CDATA[XML error : String could not be parsed as XML
XML length : 963
Original XML : <?xml version="1.0"?>
<prestashop>
<product>
<reference> OC250B </reference>
<stock_availables node_type="stock_available"/>
<id_category_default>2</id_category_default>
<id_category>2</id_category>
<redirect_type>404</redirect_type>
<available_for_order>1</available_for_order>
<show_price>1</show_price>
<minimal_quantity>1</minimal_quantity>
<active>0</active>
<price required="true" format="isPrice">5.770</price>
<id_tax_rules_group format="isUnsignedId">1</id_tax_rules_group>
<name required="true" maxSize="128" format="isCatalogName">
<language id="1">Bol salade ]]></message>
</error>
</errors>
</prestashop>

There is an error "String could not be parsed as XML"

 

I tried the PHP functions xml_encode() and xml_decode(), but it is not working.

 

Do you have an idea for this problem ?

 

 

Thanks

Edited by vik93 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Thanks Pascal !

 

I don't know if this solution is good, because now ampersands are not working   :(  

 

It is giving me the same error, and blocking the execution of my script.....

 

 

In the XML, I have &. I tried to replace this by %26amp; but also not working..... (I looked at this topic : http://www.prestashop.com/forums/topic/137890-webservice-cannot-handle-ampersands/?hl=%2Bampersands+%2Bwebservice&do=findComment&comment=1111363)

 

 

Now I think I'll have to search for 10 days again lol

 

Edit : 

 

When i use %26amp; I have a special error :

<message><![CDATA[Validation error: "Property Product->name is not valid"]]></message>
Edited by vik93 (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...