The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Your string is in UTF-8, so if you want to convert it to windows-1251, you would need to do:

PHP Code:

iconv("UTF-8", "CP1251", "Версия для печати");

If it's realistic to change, you would be wise to use UTF-8 as your encoding though, rather than windows-1251. You can not mix characters from iso-8859-1 with windows-1251, but UTF-8 contains all letters in those alphabets (and any other, for the matter) so you wouldn't get trouble mixing them.

I think you are right. It is UTF-8 encoded and needs to be displayed as windows-1251 to work. My original problem persists though - I am loading this through an AJAX call and inside a textarea and the content is showing as the UTF encoded string even though it is displayed on a windows-1251 encoded page. BUT I now have a better unserdtanding about it, and will try to solve this issue now. Thanks again for all your help!

Note that XmlHttpRequest expects data to be UTF-8, so you should make sure it is. If it ends up in the document as gibberish, it's probably because you have encoded it twice. Most likely, you're using some sort of framework/library on the PHP side, which automatically encodes the string for you. You don't want this, in this case, because the string is already in UTF-8.

One more thing to note. When you have utf-8 encoded script and open it in editor as windows-1251, you get such records as you listed. I experienced this problem when I was migrating from writing scripts in win-1251 to utf-8.

Yeah I got it all to work when I switched from the javaScript escape() function to the javascript encodeURIComponent() - that converted the string into a UTF encoded string when recieved by my PHP script (even without using urldecode()!) then all I had to do was add a header("Content-Type: text/html; charset=ASCII"); and then mb_convert_encoding($str,"CP1251","UTF-8"); in order to get the string back as "&#202;&#224;&#242;&#224;&#235;&#238;&#227;" for saving in the Joomla language file.

The meta tag is irrelevant, if you page is served by a web server, which sends content-type headers (Hint: Most web servers will). The reason is, that a meta tag is always overruled by a http-header. Make sure that your web server is sending the content-type header. In PHP, you do that with the function header

If you're not using PHP, then the page will be served by the webservers default for that file type. That is a web server configuration setting.
In you case, the pages are served with the following headers:

As you can see in the Content-Type header, the page is served as windows-1251, so that is what your content should be in. It doesn't hurt to put a meta tag, with the same information in there, but it won't have any effect either.

You can use the LiveHTTPHeaders plugin for irefox, to inspect which headers, your web page is served with.