How convert PHP value from windows-1257 to UTF-8? I tried many ways, but they was not successful. I have lttu�s and I wanna convert this to littūs.
utf8_encode();
iconv_set_encoding("windows-1257", "UTF-8");
mb_convert_encoding()
Doesn't work. :(
Can anybody help me?
$encoded= iconv ("CP1257","UTF-8", $string)
Use mb_convert_encoding($data, 'UTF-8', 'ISO-8859-13');
Have you checked that the page you are using to display the converted string has the Encoding and CodePage set correctly?
Related
I have a database with data in windows-1253 encoding.
I'm trying to convert them to utf8 with iconv function and display them in a page but I get characters like these: g óôçí åðüìåíç ôáéíßá ôïõ
Any thoughts?
This is the code I use
iconv(mb_detect_encoding($this->row["question"], mb_detect_order(), true),"UTF-8",htmlentities(stripslashes($this->row["question"])))
If you know the encoding is windows-1253, then simply try to use:
iconv('Windows-1253','UTF-8', $text);
I installed windows 7 with code page 950. Now my php with utf8 query cannot run the query in mysql. It said invalid utf8 chracter..So, my question is how can I encode the non-ascii character from code page 950 string to utf8 string?
Thanks
You could try this:
iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text);
But I don't guarantee it'll work as it's quite hard to detect the old format and convert to UTF8.
Will it be a help for you if you try mb_convert_encoding() in PHP?
i am trying to get some information from a webpage however it is in a different encoding is there an easy way to convert to utf8 and then use it?
For example i am getting these urls which i will need to visit
http://www.mega.co.il/jsfweb/cat/טופו/
http://www.mega.co.il/jsfweb/cat/גבינה_מלוחה/
http://www.mega.co.il/jsfweb/cat/גבינה_לארוח/
http://www.mega.co.il/jsfweb/cat/גבינה_מותכת/
http://www.mega.co.il/jsfweb/cat/גבינה_צהובה/
http://www.mega.co.il/jsfweb/cat/גבינה_לבנה/
http://www.mega.co.il/jsfweb/cat/קוטג/
how do i turn that to utf8 and then urlencode in php?
You can try function html_entity_decode() to decode that entities. To change decoding, use mb_convert_encoding(). I have no experience with Hebrew, so I don't know if it would work.
Hey, I'm using php 5 and need to communicate with another server that runs completely in unicode. I need to convert every string to unicode before sending it over. This seems like an easy task, but I haven't been able to find a way to do it yet. Is there a simple function that returns a unicode string? i.e. convert_to_unicode("the string i'm sending")
You can use the utf8_encode and utf8_decode functions. Also, you may need to go through Multibyte String to deal with specific encoding with those mb functions.
You can use either :
utf8_encode / utf8_decode
The mb_* Multibyte String functions ; in your case, see mb_convert_encoding
iconv and the iconv function.
You can use the function utf8_encode
Ok, iconv worked. The trouble is that this is a windows server, so I had to do it in little-endian. UTF-16LE works. Here's the working code:
iconv("UTF-8", "UTF-16LE", "data to send")
I got a .vcf file with parts encoded as UTF-8:
CATEGORIES;CHARSET=UTF-8:Straße & –dienste
Now "–" should be a "-" and "Straße" should convert to "Straße".
I tried
utf8_decode()
iconv()
mb_convert_encoding()
And have been playing with several output encoding options like
header('content-type: text/html; charset=utf-8');
mb_internal_encoding('UTF-8');
mb_http_output( "UTF-8" );
But I don't get the wanted results - instead: "StraÃ?e & â??dienste"
Anyone getting that knot out of my brain? Thanks a lot.
solved.
i had to convert the PHP file back to ISO-8859-1 (instead of UTF-8).
thought that would make no difference, but it does!
You may actually want to try utf8_encode(). I had a similar problem when retrieving UTF-8 encoded information from MySQL and displaying it on a UTF-8 HTML page.
forgot to mention: there is no MySQL...
plain php ;-)
echo "Straße & –dienste";
echo utf8_decode("Straße & –dienste");
should somehow become "Straße & -dienste"... but won't, won't, won't
I don't have an answer for you, as I'm not sure I understand fully what you are trying to do (read a .vcf file in PHP?)....
But a clue is this: "Straße" is "Straße" encoded in UTF-8, but then interpreted as Latin1 (or Windows-1252).