Odoo Help


Weird encoding issue in API call

on 9/6/16, 12:06 PM 871 views

I'm retrieving from Odoo 9 on Ubuntu 14.04 ENG a list of partners via XML-RPC using PHP and ripcord.

Some names contain one or more diacritics:

  • Pièr

  • Frère Pièr

All those names have been entered from a single computer running Windows 8.1 using one version of Chrome.

The strange fact is that I get a list where some diacritics are correct, some other have encoding problems, like:

  • Pi�r

  • Fr�re Pièr

The same diacritic in the same string is correctly encoded or not.

In subsequent calls the result is always the same.

If I edit the string, then it could change the results, giving 

  • Frère Pi�r

  • Frère Pièr

  • Fr�re Pi�r...

I need to output a JSON, and thus I need to encode this in UTF-8: but it is currently impossible since I don't have a clue of what encoding the original text is (and it seems to not have any encoding at all!)

Any idea?

On 9/8/16, 4:01 AM

I found out that the incoming array was in charset "Latin1"

I solved normalizing the array generated from the XML-RPC output, recursively applying a multbyte conversion function:

// given an XML-RPC output named $arr_output...

function descramble_diacritics(&$entry, $key) {
$entry = mb_convert_encoding($entry, 'UTF-8', 'Latin1');
array_walk_recursive($arr_output, 'descramble_diacritics');

header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
echo json_encode($arr_output);

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 9/6/16, 12:06 PM
Seen: 871 times
Last updated: 9/8/16, 4:03 AM