• Hello,

    I’m using bcn_breadcrumb to generate static breadcrumb-items, which works good. But unfortunately special characters like german Umlauts seem to be converted to json. So the output in the browser source code for ‘?’ is ‘\u00e4’. I tried to solve this with json_decode, but without success. Is there a way to correctly output special characters?

    Thank you in advance for your help!
    Andreas

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author John Havlik

    (@mtekk)

    I think we has discussed this behavior recently. If I remember correctly, in that case, the webbrowser still displayed the correct character so it was more of a ‘well that seems wrong/odd’ sort of thing. And, when I tried to recreate the problem I didn’t experience it in my testbed (the multibyte character was maintained instead of getting translated to a character code). Breadcrumb NavXT itself, should support multibyte Unicode characters without any issues (though maybe something was inadvertently introduced over time). To help me try to reproduce this, what type of resource has the umlaut in it that isn’t getting output correctly, is it a post name, a post type, a term (e.g. a tag or category), a taxonomy, or something else? Also, to rule out any odd interactions with other plugins, have you tried disabling all other plugins and seen if the problem persists?

    Thread Starter Andreas 2013

    (@andreas-2013)

    Hi John,

    thank you very much for your reply!

    Yes, you’re right, I’ve forgotten, that we discussed this problem in the past, because there were some other problems I had to solve.

    I deactivated the other plugins, but without success.

    I’m working with a custom taxonomy ‘Themen’, where the terms are ‘Schauspieler’, ‘Musiker’, and ‘Schriftsteller’. Additionally to the breadcrumb navigation, I added two static items ‘Frauen’ and ‘M?nner’, to filter the results. The URL looks like this: mydomain.com/schauspieler/maenner/

    ‘Frauen’ and ‘M?nner’ are originally query-strings, which I changed to pretty permalinks -> mydomain.com/schauspieler/?g=maenner/

    To create the breadcrumb in the browser source code I used this code in functions.php

    $new_breadcrumb = new bcn_breadcrumb('M?nner', '', array($slug), get_site_url().$_SERVER['REQUEST_URI']);
    array_splice($breadcrumb_trail->breadcrumbs, -4, 0, array($new_breadcrumb));

    The browser source code looks like this:

    <script type="application/ld+json">
    {"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https://mydomain.com","name":"My Website"}},{"@type":"ListItem","position":2,"item":{"@id":"https://mydomain.com/schauspieler/","name":"Schauspieler"}},{"@type":"ListItem","position":3,"item":{"@id":"https://mydomain.com/schauspieler/maenner/","name":"M\u00e4nner"}}]}</script>

    Do you have an idea, what causes the wrong character?

    Thanks in advance!
    Andreas

    Plugin Author John Havlik

    (@mtekk)

    Thanks for the additional information. After further investigation, this behavior seems to be due to json_encode. It looks like to get Unicode to not be escaped, I need to add the JSON_UNESCAPED_UNICODE flag to json_encode, this probably makes sense. As it stands right now, it’s technically acceptable, but changing will make it more readable. JSON and JSON-LD are supposed to be Unicode anyways so there shouldn’t be much of an issue of odd byte truncations. I’m tracking this in the following GitHub issue: https://github.com/mtekk/Breadcrumb-NavXT/issues/288

    Thread Starter Andreas 2013

    (@andreas-2013)

    Thank you very much, John!

    I’m looking forward to the update ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘bcn_breadcrumb produces special characters in source code’ is closed to new replies.