SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 25
-
Nov 22, 2007, 03:26 #1
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
[Solved] Convert "Версия для печати" to "Контакты"
I am trying to convert a string like this:
Версия для печати
Into Russian like this:
Контакты
Joomla CMS does this as the Russian language file is filled with the strange characters on the first line, but outputs the Russian characters on the 2nd line in the actual code.
Any help will be much appreciated.Last edited by CT Internet; Nov 23, 2007 at 03:20. Reason: Added [solved] to subject
Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 05:43 #2
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's UTF-8 encoded text. Send a content-type header with your page, to specify the encoding. In PHP, you can do that with:
PHP Code:header("Content-Type: text/html; encoding=utf-8");
-
Nov 22, 2007, 05:54 #3
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hej Kyber tak for det! (English: Thanks!)
But what I am looking for is a function or similar that will convert the encoded string to "Контакты"Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 05:59 #4
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I just found the function mb_detect_encoding("Âåðñèÿ äëÿ ïå÷àòè") and it returns that the encoding is ASCII
Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 06:14 #5
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have tried all of these conversions and none of them work.
echo iconv("ASCII", "Windows-1251", "Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo iconv("ASCII", "UTF-8", "Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo iconv("Windows-1251", "UTF-8", "Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo iconv("Windows-1251", "ASCII", "Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo mb_convert_encoding("Âåðñèÿ äëÿ ïå÷àòè","Windows-1251","ASCII")."<br>";
echo mb_detect_encoding("Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo utf8_decode("Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo utf8_encode("Âåðñèÿ äëÿ ïå÷àòè")."<br>";
echo convert_cyr_string("Âåðñèÿ äëÿ ïå÷àòè","k","w")."<br />";
echo convert_cyr_string("Âåðñèÿ äëÿ ïå÷àòè","i","w")."<br />";
echo convert_cyr_string("Âåðñèÿ äëÿ ïå÷àòè","a","w")."<br />";
echo convert_cyr_string("Âåðñèÿ äëÿ ïå÷àòè","d","w")."<br />";
echo convert_cyr_string("Âåðñèÿ äëÿ ïå÷àòè","m","w")."<br />";
I need to have the output as Windows-1251 as that is the encoding of the page. *sigh*
Any help is appreciated!Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 06:50 #6
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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", "Версия для печати");
-
Nov 22, 2007, 06:54 #7
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
HELP ME! I am going crazy!
I have been looking through Joomla's code and all I can see is that they include a language file full of constant definitions like this:
DEFINE('_CMN_FOLDER',"Êàòàëîã");
DEFINE('_CMN_SUBFOLDER',"Ïîäêàòàëîã");
DEFINE('_CMN_OPTIONAL',"Íå îáÿçàòåëüíî");
DEFINE('_CMN_REQUIRED',"Îáÿçàòåëüíî");
And then simply echo those onto a page with an encoding of "windows-1251".
I have tried to copy the HTML from that page and echoed my own strings and they do not appear correctly.
WHAT IS GOING ON?Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 07:04 #8
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Actually, I don't know for sure that it's UTF-8 code. It's only a good guess on my behalf, since that's usually what it is, when it's not ISO-8859-1.
Before you can convert a string, you need to figure out, which encoding it's currently in. So where did you get that string from?
-
Nov 22, 2007, 07:08 #9
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ohh - I was hoping your previous solution would have helped but it doesn't - thanks for trying though I REALLY appreciate it!
Please try to see this page: http://www.medhead.com/test.phpSoren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 07:10 #10
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The string is from a Joomla language file (in Russian) and when I run a mb_detect_encoding($str) it returns as ASCII
Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 07:23 #11
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ahh... turns out that Dreamweaver changed my content before uploading... stand by...
Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 07:23 #12
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
And which encoding does Joomla use, when using this language? You can open a page and select the browser menu View > Character Encoding (In Firefox) to see which encoding, the page is interpreted in.
You can't use mb_detect_encoding for anything here. It's just an algorithm, which makes a qualified guess on the encoding. It can't detect it with certainty, and ASCII basically means "unknown".
-
Nov 22, 2007, 07:31 #13
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OK, so now my problem is to get Javascript (AJAX) to display the string as Windows-1251. Thanks for all your help!
Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 07:34 #14
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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!
Du er sgu for genial! :-)Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 22, 2007, 08:50 #15
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Nov 22, 2007, 10:55 #16
- Join Date
- Sep 2005
- Location
- Ukraine, Nikolaev
- Posts
- 231
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Nov 23, 2007, 03:19 #17
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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 "Êàòàëîã" for saving in the Joomla language file.
Thanks for all the help and input!Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 23, 2007, 21:29 #18
- Join Date
- Apr 2007
- Posts
- 1
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I need help with encoding on www.satilir.az
If anybody knows how to fix this problem please let me know ASAP
I cant switch between english and russian when i switch to russian i always have to encode each page.
HELP HELP
-
Nov 24, 2007, 04:25 #19
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have to put:
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
In the header of your documentSoren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 24, 2007, 04:26 #20
- Join Date
- Jun 2006
- Posts
- 87
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Or if that does not work then <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Soren Beck Jensen
http://www.automaticbacklinks.com - Free link exchange network
http://www.notwebdesign.com - Joomla web design in Spain
-
Nov 24, 2007, 05:37 #21
- Join Date
- Nov 2007
- Posts
- 9
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks t2 all, i had the sam problems this the keywords
on my site http://positon.com.ua/
it looks like позитон and i didn't know how 2 repair it
-
Nov 24, 2007, 07:00 #22
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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
-
Nov 25, 2007, 01:47 #23
- Join Date
- Nov 2007
- Posts
- 9
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
but if PHP is not used.. i used only html and css on this web-site..
it seems to mee that this problem is over... before that there was another site on this place wich was written on engine... seems to me that problem was in it...
anyway thanks for everything... sorry about my poor english
-
Nov 25, 2007, 07:01 #24
- Join Date
- Jun 2004
- Location
- Copenhagen, Denmark
- Posts
- 6,157
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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:
Code:HTTP/1.x 200 OK Server: nginx/0.5.12 Date: Sun, 25 Nov 2007 12:55:47 GMT Content-Type: text/html; charset=windows-1251 Connection: keep-alive Last-Modified: Fri, 23 Nov 2007 22:22:58 GMT Etag: "1986cb-140c-474752c2" Accept-Ranges: bytes Content-Length: 5132
You can use the LiveHTTPHeaders plugin for irefox, to inspect which headers, your web page is served with.
-
Nov 25, 2007, 10:28 #25
- Join Date
- Nov 2007
- Posts
- 9
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks
Bookmarks