Odoo Help


This community 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.


Weird encoding issue in API call

on 9/6/16, 12:06 PM 165 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);

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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