Hi everyone!
I want to send cyrillic letters with php, but it is not possible because php doesn't allow it. So, how do I covert the letters so that they could be sent.

<?php if (comments_open ()) : ?>
                        <div class="comment block" id="respond">
                            <div class="holder">
                                <h2><?php comment_form_title('[B]Остави коментар[/B]', 'Leave a Reply to %s');?></h2>
           
                            </div>

I have found this: (but I don't understand how to actually combine both codes)

function html_to_utf8 ($data)
    {
    return preg_replace("/\\&\\#([0-9]{3,10})\\;/e", '_html_to_utf8("\\1")', $data);
    }

function _html_to_utf8 ($data)
    {
    if ($data > 127)
        {
        $i = 5;
        while (($i--) > 0)
            {
            if ($data != ($a = $data % ($p = pow(64, $i))))
                {
                $ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
                for ($i; $i > 0; $i--)
                    $ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
                break;
                }
            }
        }
        else
        $ret = "&#$data;";
    return $ret;
    }

Example:
echo html_to_utf8("a b &#269; &#263; &#382; &#12371; &#12395; &#12385; &#12431; ()[]{}!#$?* &lt; &#62;");

Output:
a b č ć ž こ に ち わ ()[]{}!#$?* &lt; &#62;

Thanks in advance!

did you used utf-8 encoding saving all the pages that you include? There is no need to use any function.... Just give more information about the problem...

Member Avatar for diafol

As you mention everything as UTF-8. Also be aware that Cyrillic characters ar multibyte (the usually take two bytes for each char). So if you're going to be using substr() or strlen, use the mb_substr and mb_strlen functions instead.

Thanks guys it is solved. I just took the file, saved it again with utf-8 and it worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.