seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
75 stars 39 forks source link

initialize not works for cyrillic symbols #46

Closed litvinovg closed 6 years ago

litvinovg commented 6 years ago

Looks like citepro-php implementation of CSL used in OJS can’t make initials from cyrillic given. For example with Name and middle name in latin characters it works https://pj.iph.ras.ru/index.php/ph_j/article/view/46 And with cyrillic not https://pj.iph.ras.ru/index.php/ph_j/article/view/31 That’s my csl configuration for author: \

seboettg commented 6 years ago

Looks like this occurs due to wrong character encoding. citeproc-php expects UTF-8. Before passing the JSON formatted metadata to the render function, you should convert the string to UTF-8:

$data = mb_convert_encoding($data, "UTF-8");
$citeProc->render(json_decode($data), "bibliography");
litvinovg commented 6 years ago

Thanks! I'll try it out.

seboettg commented 6 years ago

Thank you! If it is still not working, I need the metadata of some examples in order to reproduce this problem.

litvinovg commented 6 years ago

This is my citationData printed to log in json: { "type":"article-journal", "id":"31", "title":"Proclus\u2019 metaphysics: between worldview and language game. Reflections on the book of Radek Chlup", "container-title":"Philosophy Journal", "container-title-short":"PhJ", "volume":"8", "issue":"1", "section":"ACADEMIC DISCUSSIONS", "URL":"https://pj.iph.ras.ru/index.php/ph_j/article/view/31", "accessed":{ "raw":"" }, "author":[ { "family":"\u041c\u0435\u0441\u044f\u0446", "given":"\u0421\u0432\u0435\u0442\u043b\u0430\u043d\u0430 \u0412\u0438\u043a\u0442\u043e\u0440\u043e\u0432\u043d\u0430" } ], "issued":{ "raw":"2015-03-05 00:00:00" }, "page":"7-22" }

litvinovg commented 6 years ago

It seems that it is already in UTF-8. mb_convert_encoding for each data value didn't help.

seboettg commented 6 years ago

Okay, I'm going to test and debug with IEEE. The output should look as follow, right?

С. В. Месяц, “Proclus’ metaphysics: between worldview and language game. Reflections on the book of Radek Chlup,” Philosophy Journal, vol. 8, no. 1, pp. 7-22, Mar. 2015.

litvinovg commented 6 years ago

Yes.

seboettg commented 6 years ago

Okay, problem should be solved. Try out the following steps.

cd to your software root directory that uses citeproc-php and update citeproc using composer

$ composer clearcache 
$ composer require seboettg/citeproc-php:dev-hotfix/citeproc-php-46 
litvinovg commented 6 years ago

It works well now! Thanks a lot.

seboettg commented 6 years ago

Great! I'm going to merge the branch and release v2.0.4 soon.