Bonjour,
j'ai une fonction qui cherche une sous chaîne de caractères dans une chaîne et la remplace par son équivalent en gras (<strong>$sous_chaine</strong>) grâce à une regex. Le problème est que les accents ne sont pas conservés si la chaîne dans laquelle on effectue la recherche comporte des caractères accentués. J'obtiens une sorte de losanges avec des points d'interrogation à l'intérieur(&#65533;&#65533;).
Quelqu'un pourrait-il m'aider? Merci d'avance

Voici ma fonction:

function highLight($words, $str) {
    $words = preg_split("/[\s,-]+/", $words);
    $highlight = '<strong>$0</strong>';
    $pattern = '#(?!&lt;.*?)(%s)(?![^&lt;&gt;]\p{L}*?&gt;)#i';
    foreach ($words as $word) {
        $word = preg_quote($word);
        $regex = sprintf($pattern, $word); 
        $str = preg_replace($regex, $highlight, $str);
    }
    return $str;
}
Vérifie que ton fichier php soit bien encodé en UTF-8.
Cela dépend de ton éditeur.
Tu peux modifier l'encodage directement ou le faire à l'enregistrement de ton fichier.

tm
Normalement le script marche si je tape manuellement ma chaine de caractères coe tu l'as dans tom exemple. Mais les caractères que je veux afficher sont dans une variable. c'est une chaine de caractères recupérées dans un fichier xml. Et c'est là ou ca coince.
Tu as vérifié l'encodage de ton xml ?
Tu récupères les contenus de ton xml avec quelles méthodes ?
Un petit lien ou un bout de code ?

tm
Confusion. Ce n'est plus un fichier xml que j'utilise, c plutôt un fichier json. là je sais donc pas pour l'encodage. Et oui il y a un bout de code qui explore le fichier et en extrait les infos nécessaires comme la chaîne que je veux afficher.
Voici est exemple de fichier json que j'exploite.


{"result": [{"Title": "Vector ecology and susceptibility in a malaria-endemic focus in southern Islamic Republic of Iran.", "Source": "East Mediterr Health J", "PmcRefCount": 0, "Issue": "10", "ISSN": "1020-3397", "Volume": "18", "FullJournalName": "Eastern Mediterranean health journal = La revue de sante de la Mediterranee orientale = al-Majallah al-sihhiyah li-sharq al-mutawassit", "RecordStatus": "PubMed - in process", "ESSN": "1687-1634", "ELocationID": "", "Pages": "1034-41", "PubStatus": "ppublish", "AuthorList": ["Soleimani-Ahmadi M", "Vatandoost H", "Shaeghi M", "Raeisi A", "Abedi F", "Eshraghian MR", "Madani A", "Safari R", "Shahi M", "Mojahedi A", "Poorahmad-Garbandi F"], "EPubDate": "", "PubDate": "2012 Oct", "NlmUniqueID": "9608387", "LastAuthor": "Poorahmad-Garbandi F", "ArticleIds": {"rid": "23301358", "medline": [], "pubmed": ["23301358"], "eid": "23301358"}, "HasAbstract": 1, "History": {"medline": ["2013/01/11 06:00"], "entrez": "2013/01/11 06:00", "pubmed": ["2013/01/11 06:00"]}, "LangList": ["English"], "Item": [], "SO": "2012 Oct;18(10):1034-41", "PubTypeList": ["Journal Article"], "References": [], "Id": "23301358"}, {"DOI": "10.1186/1752-0509-6-S3-S5", "Title": "Module-based subnetwork alignments reveal novel transcriptional regulators in malaria parasite Plasmodium falciparum.", "Source": "BMC Syst Biol", "PmcRefCount": 0, "Issue": "", "ISSN": "", "Volume": "6 Suppl 3", "FullJournalName": "BMC systems biology", "RecordStatus": "PubMed - in process", "ESSN": "1752-0509", "ELocationID": "doi: 10.1186/1752-0509-6-S3-S5", "Pages": "S5", "PubStatus": "ppublish+epublish", "AuthorList": ["Cai H", "Hong C", "Gu J", "Lilburn TG", "Kuang R", "Wang Y"], "EPubDate": "2012 Dec 17", "PubDate": "2012", "NlmUniqueID": "101301827", "LastAuthor": "Wang Y", "ArticleIds": {"pii": "1752-0509-6-S3-S5", "medline": [], "pubmed": ["23282319"], "eid": "23282319", "rid": "23282319", "doi": "10.1186/1752-0509-6-S3-S5"}, "Item": [], "History": {"medline": ["2013/01/11 06:00"], "entrez": "2013/01/04 06:00", "aheadofprint": "2012/12/17 00:00", "pubmed": ["2013/01/11 06:00"]}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012;6 Suppl 3:S5", "PubTypeList": ["Journal Article"], "References": [], "Id": "23282319"}, {"DOI": "10.1186/1471-2105-13-S17-S18", "Title": "An automatic device for detection and classification of malaria parasite species in thick blood film.", "Source": "BMC Bioinformatics", "PmcRefCount": 0, "Issue": "", "ISSN": "", "Volume": "13 Suppl 17", "FullJournalName": "BMC bioinformatics", "RecordStatus": "PubMed - in process", "ESSN": "1471-2105", "ELocationID": "doi: 10.1186/1471-2105-13-S17-S18", "Pages": "S18", "PubStatus": "ppublish+epublish", "AuthorList": ["Kaewkamnerd S", "Uthaipibull C", "Intarapanich A", "Pannarut M", "Chaotheing S", "Tongsima S"], "EPubDate": "2012 Dec 13", "PubDate": "2012", "NlmUniqueID": "100965194", "LastAuthor": "Tongsima S", "ArticleIds": {"pii": "1471-2105-13-S17-S18", "medline": [], "pubmed": ["23281600"], "eid": "23281600", "rid": "23281600", "doi": "10.1186/1471-2105-13-S17-S18"}, "Item": [], "History": {"medline": ["2013/01/11 06:00"], "entrez": "2013/01/04 06:00", "aheadofprint": "2012/12/13 00:00", "pubmed": ["2013/01/11 06:00"]}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012;13 Suppl 17:S18", "PubTypeList": ["Journal Article"], "References": [], "Id": "23281600"}, {"DOI": "10.1371/journal.pone.0052939", "Title": "Lack of Avidity Maturation of Merozoite Antigen-Specific Antibodies with Increasing Exposure to Plasmodium falciparum amongst Children and Adults Exposed to Endemic Malaria in Kenya.", "Source": "PLoS One", "PmcRefCount": 0, "Issue": "12", "ISSN": "", "Volume": "7", "FullJournalName": "PloS one", "RecordStatus": "PubMed - in process", "ESSN": "1932-6203", "ELocationID": "doi: 10.1371/journal.pone.0052939", "Pages": "e52939", "PubStatus": "ppublish+epublish", "AuthorList": ["Ibison F", "Olotu A", "Muema DM", "Mwacharo J", "Ohuma E", "Kimani D", "Marsh K", "Bejon P", "Ndungu FM"], "EPubDate": "2012 Dec 26", "PubDate": "2012", "NlmUniqueID": "101285081", "LastAuthor": "Ndungu FM", "ArticleIds": {"pii": "PONE-D-12-27773", "medline": [], "pubmed": ["23300828"], "eid": "23300828", "rid": "23300828", "doi": "10.1371/journal.pone.0052939"}, "Item": [], "History": {"received": "2012/09/11 00:00", "medline": ["2013/01/10 06:00"], "pubmed": ["2013/01/10 06:00"], "epublish": "2012/12/26 00:00", "accepted": "2012/11/22 00:00", "entrez": "2013/01/10 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012;7(12):e52939", "PubTypeList": ["Journal Article"], "References": [], "Id": "23300828"}, {"DOI": "10.1371/journal.pone.0052870", "Title": "A Statistical Interaction between Circumsporozoite Protein-Specific T Cell and Antibody Responses and Risk of Clinical Malaria Episodes following Vaccination with RTS,S/AS01E.", "Source": "PLoS One", "PmcRefCount": 0, "Issue": "12", "ISSN": "", "Volume": "7", "FullJournalName": "PloS one", "RecordStatus": "PubMed - in process", "ESSN": "1932-6203", "ELocationID": "doi: 10.1371/journal.pone.0052870", "Pages": "e52870", "PubStatus": "ppublish+epublish", "AuthorList": ["Ndungu FM", "Mwacharo J", "Kimani D", "Kai O", "Moris P", "Jongert E", "Vekemans J", "Olotu A", "Bejon P"], "EPubDate": "2012 Dec 27", "PubDate": "2012", "NlmUniqueID": "101285081", "LastAuthor": "Bejon P", "ArticleIds": {"pii": "PONE-D-12-29312", "medline": [], "pubmed": ["23300801"], "eid": "23300801", "rid": "23300801", "doi": "10.1371/journal.pone.0052870"}, "Item": [], "History": {"received": "2012/09/25 00:00", "medline": ["2013/01/10 06:00"], "pubmed": ["2013/01/10 06:00"], "epublish": "2012/12/27 00:00", "accepted": "2012/11/21 00:00", "entrez": "2013/01/10 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012;7(12):e52870", "PubTypeList": ["Journal Article"], "References": [], "Id": "23300801"}, {"DOI": "10.1371/journal.ppat.1003099", "Title": "Statins decrease neuroinflammation and prevent cognitive impairment after cerebral malaria.", "Source": "PLoS Pathog", "PmcRefCount": 0, "Issue": "12", "ISSN": "1553-7366", "Volume": "8", "FullJournalName": "PLoS pathogens", "RecordStatus": "PubMed - in process", "ESSN": "1553-7374", "ELocationID": "doi: 10.1371/journal.ppat.1003099", "Pages": "e1003099", "PubStatus": "ppublish+epublish", "AuthorList": ["Reis PA", "Estato V", "da Silva TI", "d'Avila JC", "Siqueira LD", "Assis EF", "Bozza PT", "Bozza FA", "Tibiri\u00e7a EV", "Zimmerman GA", "Castro-Faria-Neto HC"], "EPubDate": "2012 Dec 27", "PubDate": "2012 Dec", "NlmUniqueID": "101238921", "LastAuthor": "Castro-Faria-Neto HC", "ArticleIds": {"pii": "PPATHOGENS-D-12-01593", "medline": [], "pubmed": ["23300448"], "eid": "23300448", "rid": "23300448", "doi": "10.1371/journal.ppat.1003099"}, "Item": [], "History": {"received": "2012/07/04 00:00", "medline": ["2013/01/10 06:00"], "pubmed": ["2013/01/10 06:00"], "epublish": "2012/12/27 00:00", "accepted": "2012/11/09 00:00", "entrez": "2013/01/10 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012 Dec;8(12):e1003099", "PubTypeList": ["Journal Article"], "References": [], "Id": "23300448"}, {"DOI": "10.1371/journal.ppat.1003045", "Title": "Inflammatory responses associated with the induction of cerebral malaria: lessons from experimental murine models.", "Source": "PLoS Pathog", "PmcRefCount": 0, "Issue": "12", "ISSN": "1553-7366", "Volume": "8", "FullJournalName": "PLoS pathogens", "RecordStatus": "PubMed - in process", "ESSN": "1553-7374", "ELocationID": "doi: 10.1371/journal.ppat.1003045", "Pages": "e1003045", "PubStatus": "ppublish+epublish", "AuthorList": ["Hansen DS"], "EPubDate": "2012 Dec 27", "PubDate": "2012 Dec", "NlmUniqueID": "101238921", "LastAuthor": "Hansen DS", "ArticleIds": {"pii": "PPATHOGENS-D-12-01856", "medline": [], "pubmed": ["23300435"], "eid": "23300435", "rid": "23300435", "doi": "10.1371/journal.ppat.1003045"}, "Item": [], "History": {"epublish": "2012/12/27 00:00", "medline": ["2013/01/10 06:00"], "entrez": "2013/01/10 06:00", "pubmed": ["2013/01/10 06:00"]}, "LangList": ["English"], "HasAbstract": 0, "SO": "2012 Dec;8(12):e1003045", "PubTypeList": ["Journal Article"], "References": [], "Id": "23300435"}, {"Title": "Artesunate + amodiaquine versus artemether-lumefantrine for the treatment of uncomplicated Plasmodium falciparum malaria in the Colombian Pacific region: a noninferiority trial.", "Source": "Rev Soc Bras Med Trop", "PmcRefCount": 0, "Issue": "6", "ISSN": "0037-8682", "Volume": "45", "FullJournalName": "Revista da Sociedade Brasileira de Medicina Tropical", "RecordStatus": "PubMed - in process", "ESSN": "1678-9849", "ELocationID": "", "Pages": "732-8", "PubStatus": "ppublish", "AuthorList": ["De la Hoz Restrepo F", "Porras Ram\u00edrez A", "Rico Mendoza A", "C\u00f3rdoba F", "Rojas DP"], "EPubDate": "", "PubDate": "2012 Dec", "NlmUniqueID": "7507456", "LastAuthor": "Rojas DP", "ArticleIds": {"pii": "S0037-86822012000600015", "rid": "23295878", "medline": [], "pubmed": ["23295878"], "eid": "23295878"}, "HasAbstract": 1, "History": {"medline": ["2013/01/09 06:00"], "received": "2011/11/24 00:00", "accepted": "2012/05/04 00:00", "entrez": "2013/01/09 06:00", "pubmed": ["2013/01/09 06:00"]}, "LangList": ["English"], "Item": [], "SO": "2012 Dec;45(6):732-8", "PubTypeList": ["Journal Article"], "References": [], "Id": "23295878"}, {"Title": "Enhanced T cell activation in Plasmodium falciparum malaria-infected human immunodeficiency virus-1 patients from Mozambique.", "Source": "Mem Inst Oswaldo Cruz", "PmcRefCount": 0, "Issue": "8", "ISSN": "0074-0276", "Volume": "107", "FullJournalName": "Memorias do Instituto Oswaldo Cruz", "RecordStatus": "PubMed - in process", "ESSN": "1678-8060", "ELocationID": "", "Pages": "985-92", "PubStatus": "ppublish", "AuthorList": ["Chavale H", "Santos-Oliveira JR", "Da-Cruz AM", "Enosse S"], "EPubDate": "", "PubDate": "2012 Dec", "NlmUniqueID": "7502619", "LastAuthor": "Enosse S", "ArticleIds": {"pii": "S0074-02762012000800004", "rid": "23295747", "medline": [], "pubmed": ["23295747"], "eid": "23295747"}, "HasAbstract": 1, "History": {"medline": ["2013/01/09 06:00"], "received": "2012/03/24 00:00", "accepted": "2012/08/16 00:00", "entrez": "2013/01/09 06:00", "pubmed": ["2013/01/09 06:00"]}, "LangList": ["English"], "Item": [], "SO": "2012 Dec;107(8):985-92", "PubTypeList": ["Journal Article"], "References": [], "Id": "23295747"}, {"DOI": "10.2217/FVL.12.59", "Title": "The effect of HIV on malaria in the context of the current standard of care for HIV-infected populations in Africa.", "Source": "Future Virol", "PmcRefCount": 0, "Issue": "7", "ISSN": "1746-0794", "Volume": "7", "FullJournalName": "Future virology", "RecordStatus": "PubMed", "ESSN": "1746-0808", "ELocationID": "", "Pages": "699-708", "PubStatus": "ppublish", "AuthorList": ["Kamya MR", "Byakika-Kibwika P", "Gasasira AF", "Havlir D", "Rosenthal PJ", "Dorsey G", "Achan J"], "EPubDate": "", "PubDate": "2012", "NlmUniqueID": "101278124", "LastAuthor": "Achan J", "ArticleIds": {"medline": [], "mid": "NIHMS406043", "pubmed": ["23293660"], "eid": "23293660", "pmc": "PMC3535690", "rid": "23293660", "pmcid": "pmc-id: PMC3535690;manuscript-id: NIHMS406043;", "doi": "10.2217/FVL.12.59"}, "Item": [], "History": {"medline": ["2013/01/08 06:00"], "entrez": "2013/01/08 06:00", "pubmed": ["2013/01/08 06:00"]}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012;7(7):699-708", "PubTypeList": ["Journal Article"], "References": [], "Id": "23293660"}, {"DOI": "10.1016/j.jiph.2012.09.016", "Title": "Determining the severity of Plasmodium falciparum malaria in Ethiopia.", "Source": "J Infect Public Health", "PmcRefCount": 0, "Issue": "1", "ISSN": "1876-0341", "Volume": "6", "FullJournalName": "Journal of infection and public health", "RecordStatus": "PubMed - in process", "ESSN": "1876-035X", "ELocationID": "doi: 10.1016/j.jiph.2012.09.016", "Pages": "10-5", "PubStatus": "ppublish+epublish", "AuthorList": ["Tekeste Z", "Workineh M", "Petros B"], "EPubDate": "2012 Nov 21", "PubDate": "2013 Feb", "NlmUniqueID": "101487384", "LastAuthor": "Petros B", "ArticleIds": {"pii": "S1876-0341(12)00132-3", "medline": [], "pubmed": ["23290088"], "eid": "23290088", "rid": "23290088", "doi": "10.1016/j.jiph.2012.09.016"}, "Item": [], "History": {"received": "2012/05/11 00:00", "medline": ["2013/01/08 06:00"], "revised": "2012/09/12 00:00", "pubmed": ["2013/01/08 06:00"], "aheadofprint": "2012/11/21 00:00", "accepted": "2012/09/22 00:00", "entrez": "2013/01/08 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2013 Feb;6(1):10-5", "PubTypeList": ["Journal Article"], "References": [], "Id": "23290088"}, {"DOI": "10.1016/j.bmcl.2012.12.032", "Title": "In vitro efficiency of 9-(N-cinnamoylbutyl)aminoacridines against blood- and liver-stage malaria parasites.", "Source": "Bioorg Med Chem Lett", "PmcRefCount": 0, "Issue": "", "ISSN": "0960-894X", "Volume": "", "FullJournalName": "Bioorganic & medicinal chemistry letters", "RecordStatus": "PubMed - as supplied by publisher", "ESSN": "1464-3405", "ELocationID": "pii: S0960-894X(12)01616-2. doi: 10.1016/j.bmcl.2012.12.032", "Pages": "", "PubStatus": "aheadofprint", "AuthorList": ["P\u00e9rez B", "Teixeira C", "Gomes AS", "Albuquerque IS", "Gut J", "Rosenthal PJ", "Prud\u00eancio M", "Gomes P"], "EPubDate": "2012 Dec 21", "PubDate": "2012 Dec 21", "NlmUniqueID": "9107377", "LastAuthor": "Gomes P", "ArticleIds": {"pii": "S0960-894X(12)01616-2", "medline": [], "pubmed": ["23290049"], "eid": "23290049", "rid": "23290049", "doi": "10.1016/j.bmcl.2012.12.032"}, "Item": [], "History": {"received": "2012/11/08 00:00", "medline": ["2013/01/08 06:00"], "revised": "2012/12/10 00:00", "pubmed": ["2013/01/08 06:00"], "accepted": "2012/12/11 00:00", "entrez": "2013/01/08 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012 Dec 21;", "PubTypeList": ["Journal Article"], "References": [], "Id": "23290049"}, {"Title": "A spatial statistical approach to analyze malaria situation at micro level for priority control in Ranchi district, Jharkhand.", "Source": "Indian J Med Res", "PmcRefCount": 0, "Issue": "5", "ISSN": "0971-5916", "Volume": "136", "FullJournalName": "The Indian journal of medical research", "RecordStatus": "PubMed - in process", "ESSN": "", "ELocationID": "", "Pages": "776-82", "PubStatus": "ppublish", "AuthorList": ["Saxena R", "Nagpal BN", "Das MK", "Srivastava A", "Gupta SK", "Kumar A", "Jeyaseelan AT", "Baraik VK"], "EPubDate": "", "PubDate": "2012 Nov", "NlmUniqueID": "0374701", "LastAuthor": "Baraik VK", "ArticleIds": {"pii": "IndianJMedRes_2012_136_5_776_105413", "rid": "23287124", "medline": [], "pubmed": ["23287124"], "eid": "23287124"}, "HasAbstract": 1, "History": {"medline": ["2013/01/05 06:00"], "entrez": "2013/01/05 06:00", "pubmed": ["2013/01/05 06:00"]}, "LangList": ["English"], "Item": [], "SO": "2012 Nov;136(5):776-82", "PubTypeList": ["Journal Article"], "References": [], "Id": "23287124"}, {"DOI": "10.4081/hr.2011.e24", "Title": "Sickle cell protection from malaria.", "Source": "Hematol Rep", "PmcRefCount": 0, "Issue": "3", "ISSN": "2038-8322", "Volume": "3", "FullJournalName": "Hematology reports", "RecordStatus": "PubMed", "ESSN": "2038-8330", "ELocationID": "doi: 10.4081/hr.2011.e24", "Pages": "e24", "PubStatus": "ppublish+epublish", "AuthorList": ["Eridani S"], "EPubDate": "2011 Nov 4", "PubDate": "2011 Oct 19", "NlmUniqueID": "101556723", "LastAuthor": "Eridani S", "ArticleIds": {"pii": "hr.2011.e24", "medline": [], "pubmed": ["23285410"], "eid": "23285410", "pmc": "PMC3269803", "rid": "23285410", "pmcid": "pmc-id: PMC3269803;", "doi": "10.4081/hr.2011.e24"}, "Item": [], "History": {"received": "2011/07/27 00:00", "medline": ["2011/10/19 00:01"], "pubmed": ["2011/10/19 00:00"], "epublish": "2011/11/04 00:00", "accepted": "2011/10/12 00:00", "entrez": "2013/01/04 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2011 Oct 19;3(3):e24", "PubTypeList": ["Journal Article"], "References": [], "Id": "23285410"}, {"DOI": "10.5581/1516-8484.20110016", "Title": "Duffy Blood Group System and the malaria adaptation process in humans.", "Source": "Rev Bras Hematol Hemoter", "PmcRefCount": 0, "Issue": "1", "ISSN": "1516-8484", "Volume": "33", "FullJournalName": "Revista brasileira de hematologia e hemoterapia", "RecordStatus": "PubMed", "ESSN": "1806-0870", "ELocationID": "doi: 10.5581/1516-8484.20110016", "Pages": "55-64", "PubStatus": "ppublish", "AuthorList": ["de Carvalho GB", "de Carvalho GB"], "EPubDate": "", "PubDate": "2011", "NlmUniqueID": "101220159", "LastAuthor": "de Carvalho GB", "ArticleIds": {"medline": [], "pubmed": ["23284245"], "eid": "23284245", "pmc": "PMC3521437", "rid": "23284245", "pmcid": "pmc-id: PMC3521437;", "doi": "10.5581/1516-8484.20110016"}, "Item": [], "History": {"medline": ["2011/01/01 00:01"], "received": "2010/01/12 00:00", "accepted": "2011/02/04 00:00", "entrez": "2013/01/04 06:00", "pubmed": ["2011/01/01 00:00"]}, "LangList": ["English"], "HasAbstract": 1, "SO": "2011;33(1):55-64", "PubTypeList": ["Journal Article"], "References": [], "Id": "23284245"}, {"Title": "What do malaria, rheumatoid arthritis, systemic lupus erythematosus and ulcerative colitis have in common?", "Source": "Inflamm Bowel Dis", "PmcRefCount": 0, "Issue": "3", "ISSN": "1078-0998", "Volume": "3", "FullJournalName": "Inflammatory bowel diseases", "RecordStatus": "PubMed", "ESSN": "1536-4844", "ELocationID": "", "Pages": "244-5", "PubStatus": "ppublish", "AuthorList": ["Mayer L"], "EPubDate": "", "PubDate": "1997 Fall", "NlmUniqueID": "9508162", "LastAuthor": "Mayer L", "ArticleIds": {"pii": "00054725-199709000-00013", "rid": "23282814", "medline": [], "pubmed": ["23282814"], "eid": "23282814"}, "HasAbstract": 1, "History": {"medline": ["1997/10/01 00:01"], "entrez": "2013/01/04 06:00", "pubmed": ["1997/10/01 00:00"]}, "LangList": ["English"], "Item": [], "SO": "1997 Fall;3(3):244-5", "PubTypeList": ["Journal Article"], "References": [], "Id": "23282814"}, {"DOI": "10.1371/journal.pone.0052719", "Title": "Optimized Pan-species and Speciation Duplex Real-time PCR Assays for Plasmodium Parasites Detection in Malaria Vectors.", "Source": "PLoS One", "PmcRefCount": 0, "Issue": "12", "ISSN": "", "Volume": "7", "FullJournalName": "PloS one", "RecordStatus": "PubMed - in process", "ESSN": "1932-6203", "ELocationID": "doi: 10.1371/journal.pone.0052719", "Pages": "e52719", "PubStatus": "ppublish+epublish", "AuthorList": ["Sandeu MM", "Moussiliou A", "Moiroux N", "Padonou GG", "Massougbodji A", "Corbel V", "Tuikue Ndam N"], "EPubDate": "2012 Dec 28", "PubDate": "2012", "NlmUniqueID": "101285081", "LastAuthor": "Tuikue Ndam N", "ArticleIds": {"pii": "PONE-D-12-23281", "medline": [], "pubmed": ["23285168"], "eid": "23285168", "pmc": "PMC3532469", "rid": "23285168", "pmcid": "pmc-id: PMC3532469;", "doi": "10.1371/journal.pone.0052719"}, "Item": [], "History": {"received": "2012/08/03 00:00", "medline": ["2013/01/04 06:00"], "pubmed": ["2013/01/04 06:00"], "epublish": "2012/12/28 00:00", "accepted": "2012/11/20 00:00", "entrez": "2013/01/04 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012;7(12):e52719", "PubTypeList": ["Journal Article"], "References": [], "Id": "23285168"}, {"Title": "Association between Climatic Variables and Malaria Incidence: A Study in Kokrajhar District of Assam, India.", "Source": "Glob J Health Sci", "PmcRefCount": 0, "Issue": "1", "ISSN": "1916-9736", "Volume": "5", "FullJournalName": "Global journal of health science", "RecordStatus": "PubMed - in process", "ESSN": "1916-9744", "ELocationID": "doi: 10.5539/gjhs.v5n1p90", "Pages": "90-106", "PubStatus": "epublish", "AuthorList": ["Nath DC", "Mwchahary DD"], "EPubDate": "2012 Nov 11", "PubDate": "2012 Nov 11", "NlmUniqueID": "101519495", "LastAuthor": "Mwchahary DD", "ArticleIds": {"rid": "23283041", "medline": [], "pubmed": ["23283041"], "eid": "23283041"}, "HasAbstract": 1, "History": {"medline": ["2013/01/04 06:00"], "received": "2012/10/07 00:00", "accepted": "2012/10/22 00:00", "entrez": "2013/01/04 06:00", "pubmed": ["2013/01/04 06:00"]}, "LangList": ["English"], "Item": [], "SO": "2012 Nov 11;5(1):90-106", "PubTypeList": ["Journal Article"], "References": [], "Id": "23283041"}, {"DOI": "10.1590/S0034-98872012000800021", "Title": "[Similarities and differences between deaths due to abortion and malaria].", "Source": "Rev Med Chil", "PmcRefCount": 0, "Issue": "8", "ISSN": "0034-9887", "Volume": "140", "FullJournalName": "Revista medica de Chile", "RecordStatus": "PubMed - in process", "ESSN": "0717-6163", "ELocationID": "doi: 10.1590/S0034-98872012000800021", "Pages": "1089-91", "PubStatus": "ppublish", "AuthorList": ["Mart\u00ednez EA"], "EPubDate": "", "PubDate": "2012 Aug", "NlmUniqueID": "0404312", "LastAuthor": "Mart\u00ednez EA", "ArticleIds": {"pii": "S0034-98872012000800021", "medline": [], "pubmed": ["23282788"], "eid": "23282788", "rid": "23282788", "doi": "10.1590/S0034-98872012000800021"}, "Item": [], "History": {"medline": ["2013/01/04 06:00"], "entrez": "2013/01/04 06:00", "pubmed": ["2013/01/04 06:00"]}, "LangList": ["Spanish"], "HasAbstract": 0, "SO": "2012 Aug;140(8):1089-91", "PubTypeList": ["Journal Article"], "References": [], "Id": "23282788"}, {"DOI": "10.1111/micc.12034", "Title": "A chronic scheme of cranial window preparation to study pial vascular reactivity in murine cerebral malaria.", "Source": "Microcirculation", "PmcRefCount": 0, "Issue": "", "ISSN": "1073-9688", "Volume": "", "FullJournalName": "Microcirculation (New York, N.Y. : 1994)", "RecordStatus": "PubMed - as supplied by publisher", "ESSN": "1549-8719", "ELocationID": "doi: 10.1111/micc.12034", "Pages": "", "PubStatus": "aheadofprint", "AuthorList": ["Ong PK", "Meays D", "Frangos JA", "Carvalho LJ"], "EPubDate": "2012 Dec 20", "PubDate": "2012 Dec 20", "NlmUniqueID": "9434935", "LastAuthor": "Carvalho LJ", "ArticleIds": {"rid": "23279271", "medline": [], "pubmed": ["23279271"], "eid": "23279271", "doi": "10.1111/micc.12034"}, "Item": [], "History": {"received": "2012/10/29 00:00", "medline": ["2013/01/03 06:00"], "revised": "2012/12/13 00:00", "pubmed": ["2013/01/03 06:00"], "accepted": "2012/12/14 00:00", "entrez": "2013/01/03 06:00"}, "LangList": ["English"], "HasAbstract": 1, "SO": "2012 Dec 20;", "PubTypeList": ["Journal Article"], "References": [], "Id": "23279271"}], "entrezajax": {"count": "29612", "retmax": "20", "error": false}}
Le code qui l'exploite est le suivant:

<?php
    $serverurl = 'http://entrezajax.appspot.com/esearch+esummary?db=pubmed&term='.$disp['pm_terms'].'&retstart='.$start.'&retmax='.$retmax.'&apikey=191d24f81e61c107bca103f7d6a9ca10';

    $curl = new curl;
    $resp = $curl->get($serverurl);

    $obj = json_decode(utf8_encode($resp));

    $tab = $obj->{'result'};
    $entrezajax = $obj->{'entrezajax'};
				
    if ($entrezajax->{'error'} == false) {
        if ((int)$entrezajax->{'count'} != 0) {
	    for ($i=0; $i<count($tab); $i++) {
                $authorsTab = $tab[$i]->{'AuthorList'};
                for ($j=0; $j<count($authorsTab); $j++) {
		    if ($j != count($authorsTab)-1) $authorslist[$i] .= $authorsTab[$j].', ';
		    else $authorslist[$i] .= $authorsTab[$j];
	        }
               echo '<p>'.highlight($text, $authorlist[$i]).'</p>';
            } 
        }
    }   


Ce qui est bizarre c'est que sans l'utilisation de la fonction highlight les caractères accentués s'affiche très bien. Ce qui me pousse à penser le problème est au niveau de l'expression régulière et du preg_replace.
Modifié par yveslands (11 Jan 2013 - 13:21)
Re,

Pourquoi utilises-tu "utf8_encode()" ?
C'est toi qui génère le JSON ?

J'ai ajouté qqs accents dans le premier nom pour faire un test et n'ai pas de soucis particuliers...

tm
en fait le code marche sauf pour $text = null et $text = ' '.
Dans le premier cas au lieu des losanges et dans le deuxième une inondation de balise <strong>. Une idée peut etre?
Ok c bon. une simple condition if avant l'affichage règle ce problème. Mais il en demeure un autre. Quand j'execute le code avec
$text = 'cordoba'
rien ne se passe pourtant il existe 'Córdoba' dans la chaine de recherche. voici ma regex:
$pattern = '#(?!&lt;.*?)(%s)(?![^&lt;&gt;]\p{L}*?&gt;)#iu';

est-ce correct?