سؤال

fm API to get event discription, venue name etc...

Now sometimes I get special chars back like: ' é à , but they show up scrabled.

So how can I display them properly? Also with the descrioption I get html-tags back, but I do want to keep these.

Can someone help me out fot those both cases? The language I'm using is php

Thanks in advance

هل كانت مفيدة؟

المحلول

  • specify encoding in the header:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    

    ...

  • encode string when handling the input

    $str=utf8_encode($str);

  • if you are displaying the input back as-is, no encoding is required; however, if the value is the content of an input or textarea, escape the html characters

    <?php echo htmlspecialchars($str); ?>

نصائح أخرى

For Latin characters, use

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

in your section.

you need to be sure about two things, the meta header referring to which enconding you will be using, and the encoding you are using for the text served.

If you are using a utf8 header just be sure to convert the text served to utf8, refer to functions for encoding conversion like : mb_convert_encoding

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top